@blac/react 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blac-react.d.ts +8 -2
- package/dist/blac-react.esm.js +10 -1
- package/dist/blac-react.esm.js.map +1 -1
- package/dist/blac-react.js +10 -0
- package/dist/blac-react.js.map +1 -1
- package/package.json +1 -1
package/dist/blac-react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Blac, BlocBase, ValueType, BlocClass } from 'blac';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { FC, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
declare const BlacContext: React.Context<Blac<any, any> | null>;
|
|
5
5
|
|
|
@@ -14,6 +14,12 @@ interface ProviderItem {
|
|
|
14
14
|
bloc: BlocBase<any>;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
declare const BlocProvider: FC<{
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
bloc: (() => BlocBase<any>) | BlocBase<any>;
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
|
|
17
23
|
interface ExternalStore<B extends BlocBase<any>> {
|
|
18
24
|
subscribe: (onStoreChange: () => void) => () => void;
|
|
19
25
|
getSnapshot: () => ValueType<B>;
|
|
@@ -33,4 +39,4 @@ interface BlocHookOptions {
|
|
|
33
39
|
}
|
|
34
40
|
declare const useBloc: <B extends BlocBase<S>, S>(bloc: BlocClass<B> | (() => B), options?: BlocHookOptions) => BlocHookData<B, S>;
|
|
35
41
|
|
|
36
|
-
export { BlacContext, BlocHookData, BlocHookOptions, ExternalStore, ProviderItem, useBloc };
|
|
42
|
+
export { BlacContext, BlocHookData, BlocHookOptions, BlocProvider, ExternalStore, ProviderItem, useBloc };
|
package/dist/blac-react.esm.js
CHANGED
|
@@ -135,6 +135,15 @@ class BlacReact {
|
|
|
135
135
|
|
|
136
136
|
const BlacContext = createContext(null);
|
|
137
137
|
|
|
138
|
+
const BlocProvider = ({ children, bloc, debug }) => {
|
|
139
|
+
const blacReact = BlacReact.getInstance();
|
|
140
|
+
const providerId = blacReact.useLocalProvider({ bloc, debug });
|
|
141
|
+
if (!providerId) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
return (React.createElement(blacReact.LocalProvider, { value: providerId }, children));
|
|
145
|
+
};
|
|
146
|
+
|
|
138
147
|
const externalBlocStore = (bloc) => {
|
|
139
148
|
return {
|
|
140
149
|
subscribe: (listener) => {
|
|
@@ -192,5 +201,5 @@ const useBloc = (bloc, options = {}) => {
|
|
|
192
201
|
return [state, resolvedBloc];
|
|
193
202
|
};
|
|
194
203
|
|
|
195
|
-
export { BlacContext, useBloc };
|
|
204
|
+
export { BlacContext, BlocProvider, useBloc };
|
|
196
205
|
//# sourceMappingURL=blac-react.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blac-react.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blac-react.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/blac-react.js
CHANGED
|
@@ -137,6 +137,15 @@ class BlacReact {
|
|
|
137
137
|
|
|
138
138
|
const BlacContext = React.createContext(null);
|
|
139
139
|
|
|
140
|
+
const BlocProvider = ({ children, bloc, debug }) => {
|
|
141
|
+
const blacReact = BlacReact.getInstance();
|
|
142
|
+
const providerId = blacReact.useLocalProvider({ bloc, debug });
|
|
143
|
+
if (!providerId) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return (React.createElement(blacReact.LocalProvider, { value: providerId }, children));
|
|
147
|
+
};
|
|
148
|
+
|
|
140
149
|
const externalBlocStore = (bloc) => {
|
|
141
150
|
return {
|
|
142
151
|
subscribe: (listener) => {
|
|
@@ -195,5 +204,6 @@ const useBloc = (bloc, options = {}) => {
|
|
|
195
204
|
};
|
|
196
205
|
|
|
197
206
|
exports.BlacContext = BlacContext;
|
|
207
|
+
exports.BlocProvider = BlocProvider;
|
|
198
208
|
exports.useBloc = useBloc;
|
|
199
209
|
//# sourceMappingURL=blac-react.js.map
|
package/dist/blac-react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blac-react.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blac-react.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|