Skip to content

Commit

Permalink
feat(exports): added store context and useStore to exports
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Jan 16, 2020
1 parent c079466 commit f022ff3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export {
export {
factoryParameters,
useBatchQuery,
DEFAULT_NAMESPACE
useStore,
DEFAULT_NAMESPACE,
StoreContext
} from './lib/store'
export { pm } from './lib/utils'
15 changes: 10 additions & 5 deletions src/lib/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,17 @@ export const geschichte = <T = object>(

type InitialValuesProvider<T = object> = T | (() => T)

export const useBatchQuery = () => {
const [useStore] = useContext(StoreContext) as [
UseStore<StoreState<any>>,
StoreApi<StoreState<any>>
export const useStore = <T = any>() => {
const [store] = useContext(StoreContext) as [
UseStore<StoreState<T>>,
StoreApi<StoreState<T>>
]
return useStore(
return store
}

export const useBatchQuery = <T = any>() => {
const store = useStore<T>()
return store(
({ batchPushState, batchReplaceState }) => ({
batchPushState,
batchReplaceState
Expand Down

0 comments on commit f022ff3

Please sign in to comment.