@blac/react
Advanced tools
Comparing version 0.0.2 to 0.0.3
import { Blac, BlocBase, ValueType, BlocClass } from 'blac'; | ||
import React from 'react'; | ||
import React, { FC, ReactNode } from 'react'; | ||
@@ -17,2 +17,8 @@ declare const BlacContext: React.Context<Blac<any, any> | null>; | ||
declare const BlocProvider: FC<{ | ||
children?: ReactNode; | ||
bloc: (() => BlocBase<any>) | BlocBase<any>; | ||
debug?: boolean; | ||
}>; | ||
interface ExternalStore<B extends BlocBase<any>> { | ||
@@ -37,2 +43,2 @@ subscribe: (onStoreChange: () => void) => () => void; | ||
export { BlacContext, BlocHookData, BlocHookOptions, ExternalStore, ProviderItem, useBloc }; | ||
export { BlacContext, BlocHookData, BlocHookOptions, BlocProvider, ExternalStore, ProviderItem, useBloc }; |
@@ -138,2 +138,11 @@ import React, { useContext, useMemo, useEffect, createContext, useSyncExternalStore } from 'react'; | ||
const BlocProvider = ({ children, bloc, debug }) => { | ||
const blacReact = BlacReact.getInstance(); | ||
const providerId = blacReact.useLocalProvider({ bloc, debug }); | ||
if (!providerId) { | ||
return null; | ||
} | ||
return (React.createElement(blacReact.LocalProvider, { value: providerId }, children)); | ||
}; | ||
const externalBlocStore = (bloc) => { | ||
@@ -196,3 +205,3 @@ return { | ||
export { BlacContext, useBloc }; | ||
export { BlacContext, BlocProvider, useBloc }; | ||
//# sourceMappingURL=blac-react.esm.js.map |
@@ -140,2 +140,11 @@ 'use strict'; | ||
const BlocProvider = ({ children, bloc, debug }) => { | ||
const blacReact = BlacReact.getInstance(); | ||
const providerId = blacReact.useLocalProvider({ bloc, debug }); | ||
if (!providerId) { | ||
return null; | ||
} | ||
return (React.createElement(blacReact.LocalProvider, { value: providerId }, children)); | ||
}; | ||
const externalBlocStore = (bloc) => { | ||
@@ -199,3 +208,4 @@ return { | ||
exports.BlacContext = BlacContext; | ||
exports.BlocProvider = BlocProvider; | ||
exports.useBloc = useBloc; | ||
//# sourceMappingURL=blac-react.js.map |
{ | ||
"name": "@blac/react", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/blac-react.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
17656
436