cra-template-demplate
Advanced tools
Comparing version 0.2.5 to 0.2.6
{ | ||
"name": "cra-template-demplate", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "react", |
@@ -7,7 +7,6 @@ import {Middleware} from '@/utils/zustand'; | ||
get, | ||
store, | ||
$$storeMutations | ||
store | ||
) => config(args => { | ||
set(args); | ||
console.log('TODO: Add custom middleware logic here'); | ||
}, get, store, $$storeMutations); | ||
}, get, store); |
@@ -1,3 +0,4 @@ | ||
import {applyMiddleware, logMiddleware, StoreInterface} from '@/utils/zustand'; | ||
import {syncMiddlewareCreator} from '@/utils/syncMiddleware'; | ||
import {applyMiddleware, logMiddleware, Middleware} from '@/utils/zustand'; | ||
import {persistMiddlewareCreator} from '@/utils/persist2Middleware'; | ||
import {StateCreator} from 'zustand'; | ||
@@ -18,3 +19,3 @@ export enum Locale { | ||
const store: StoreInterface<Store> = (set) => ({ | ||
const store: StateCreator<Store> = (set) => ({ | ||
locale: defaultLocale, | ||
@@ -25,7 +26,7 @@ setLocale: (locale: Locale) => set(() => ({locale})) | ||
export const useLocaleStore = applyMiddleware<Store>(store, [ | ||
syncMiddlewareCreator({ | ||
persistMiddlewareCreator({ | ||
name: 'locale', | ||
syncDynamically: true | ||
}), | ||
}) as Middleware<Store>, | ||
logMiddleware | ||
]); |
@@ -1,4 +0,5 @@ | ||
import {applyMiddleware, logMiddleware, StoreInterface} from '@/utils/zustand'; | ||
import {applyMiddleware, logMiddleware} from '@/utils/zustand'; | ||
import {sleep} from '@/utils'; | ||
import {testMiddleware} from '@/middleware/test'; | ||
import {StateCreator} from 'zustand'; | ||
@@ -15,3 +16,3 @@ export interface Test { | ||
const store: StoreInterface<Test> = (set, get) => ({ | ||
const store: StateCreator<Test> = (set, get) => ({ | ||
a: 0, | ||
@@ -18,0 +19,0 @@ b: 0, |
import create, {GetState, SetState, StateCreator, StoreApi} from 'zustand'; | ||
import {log} from '@/utils/index'; | ||
export type StoreInterface<T extends {}> = ( | ||
set: SetState<T>, | ||
get: GetState<T>, | ||
api: StoreApi<T>, | ||
$$storeMutations: any | ||
) => T; | ||
export type Middleware<T extends {}> = ( | ||
config: StateCreator<T>, | ||
) => StoreInterface<T>; | ||
) => StateCreator<T>; | ||
export const applyMiddleware = <T extends {}>(s: StoreInterface<T>, middlewares: Middleware<T>[]) => create<T>( | ||
export const applyMiddleware = <T extends {}>(s: StateCreator<T>, middlewares: Middleware<T>[]) => create<T>( | ||
middlewares.reduce((a, m) => m(a), s) | ||
@@ -22,4 +15,3 @@ ); | ||
get: GetState<T>, | ||
store: StoreApi<T>, | ||
$$storeMutations: any | ||
store: StoreApi<T> | ||
) => config(args => { | ||
@@ -29,2 +21,2 @@ log(' applying', args); | ||
log(' new state', get()); | ||
}, get, store, $$storeMutations); | ||
}, get, store); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51775
885