fluxible-js
Advanced tools
Comparing version 6.0.5 to 6.0.6
@@ -1,19 +0,19 @@ | ||
declare type AsyncPersist<T> = { | ||
declare type AsyncPersist<StoreType> = { | ||
asyncStorage: { | ||
getItem: (key: string) => Promise<string | Record<string, any>>; | ||
setItem: (key: string, value: string | T) => Promise<any>; | ||
setItem: (key: string, value: string | StoreType) => Promise<any>; | ||
}; | ||
restore: (savedStore: T) => Partial<T>; | ||
restore: (savedStore: StoreType) => Partial<StoreType>; | ||
}; | ||
declare type SyncPersist<T> = { | ||
declare type SyncPersist<StoreType> = { | ||
syncStorage: { | ||
getItem: (key: string) => string; | ||
setItem: (key: string, value: string | T) => void; | ||
setItem: (key: string, value: string | StoreType) => void; | ||
}; | ||
restore: (savedStore: T) => Partial<T>; | ||
restore: (savedStore: StoreType) => Partial<StoreType>; | ||
}; | ||
declare type Config<T> = { | ||
initialStore: T; | ||
declare type Config<StoreType> = { | ||
initialStore: StoreType; | ||
useJSON?: boolean; | ||
persist?: AsyncPersist<T> | SyncPersist<T>; | ||
persist?: AsyncPersist<StoreType> | SyncPersist<StoreType>; | ||
}; | ||
@@ -20,0 +20,0 @@ export declare type Store<StoreType> = { |
{ | ||
"name": "fluxible-js", | ||
"version": "6.0.5", | ||
"version": "6.0.6", | ||
"description": "Smaller, faster, better state management system that supports asynchronicity and state persistence out of the box.", | ||
@@ -15,3 +15,2 @@ "main": "lib/index.js", | ||
"test": "npm run build && jest __tests__/unit/* --env=node --coverage", | ||
"webpack": "rm -rf build && webpack", | ||
"build": "rm -rf lib && mkdir lib && npm run lint && tsc", | ||
@@ -72,6 +71,3 @@ "eslint": "eslint . --ext .js,.ts --fix", | ||
"lint-staged": "^11.2.6", | ||
"prettier": "^2.4.1", | ||
"webpack": "^5.51.1", | ||
"webpack-cli": "^4.8.0", | ||
"webpack-loader-clean-pragma": "^1.0.2" | ||
"prettier": "^2.4.1" | ||
}, | ||
@@ -78,0 +74,0 @@ "dependencies": { |
@@ -30,14 +30,12 @@ ![npm](https://img.shields.io/npm/dt/fluxible-js) ![npm](https://img.shields.io/npm/dm/fluxible-js) ![npm](https://img.shields.io/npm/dw/fluxible-js) | ||
function getInitialStore() { | ||
return { | ||
user: null, | ||
someOtherState: 'value', | ||
anotherState: { | ||
value: 'value' | ||
} | ||
}; | ||
} | ||
const initialStore = { | ||
user: null, | ||
someOtherState: 'value', | ||
anotherState: { | ||
value: 'value' | ||
} | ||
}; | ||
const store = createStore<ReturnType<typeof getInitialStore>>({ | ||
initialStore: getInitialStore(), | ||
const store = createStore({ | ||
initialStore, | ||
persist: { | ||
@@ -58,15 +56,11 @@ useJSON: false, | ||
function getInitialStore() { | ||
return { | ||
user: null, | ||
someOtherState: 'value', | ||
anotherState: { | ||
value: 'value' | ||
} | ||
}; | ||
} | ||
const initialStore = { | ||
user: null, | ||
someOtherState: 'value', | ||
anotherState: { | ||
value: 'value' | ||
} | ||
}; | ||
const myStore = createStore<ReturnType<typeof getInitialStore>>({ | ||
initialStore: getInitialStore() | ||
}); | ||
const myStore = createStore({ initialStore }); | ||
``` | ||
@@ -96,3 +90,3 @@ | ||
const store = createStore<typeof initialStore>({ | ||
const store = createStore({ | ||
initialStore, | ||
@@ -122,3 +116,3 @@ persist: { | ||
const store = createStore<typeof initialStore>({ | ||
const store = createStore({ | ||
initialStore, | ||
@@ -148,3 +142,3 @@ persist: { | ||
const store = createStore<typeof initialStore>({ | ||
const store = createStore({ | ||
initialStore, | ||
@@ -289,3 +283,3 @@ persist: { | ||
export default createStore<typeof initialStore>({ | ||
export default createStore({ | ||
initialStore, | ||
@@ -292,0 +286,0 @@ // ... other options |
23
91836
285