Gathering detailed insights and metrics for mobx-persist
Gathering detailed insights and metrics for mobx-persist
Gathering detailed insights and metrics for mobx-persist
Gathering detailed insights and metrics for mobx-persist
npm install mobx-persist
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
560 Stars
109 Commits
62 Forks
11 Watching
2 Branches
7 Contributors
Updated on 23 Oct 2024
Minified
Minified + Gzipped
TypeScript (61.89%)
JavaScript (36.8%)
HTML (1.31%)
Cumulative downloads
Total Downloads
Last day
-24.2%
1,236
Compared to previous day
Last week
-5.6%
7,038
Compared to previous week
Last month
24%
33,768
Compared to previous month
Last year
-22.3%
429,167
Compared to previous year
$ npm install mobx-persist --save
1import { observable } from 'mobx' 2import { create, persist } from 'mobx-persist' 3 4class SomeItem { 5 @persist @observable name = 'some' 6 @persist @observable count = 0 7} 8 9class SomeStore { 10 @persist('object') @observable obj = { a: 1, b: 2 } 11 @persist('map') @observable stringMap = observable.map<string>({}) 12 @persist('list') @observable numList = [1,2,3,4] 13 @persist('object', SomeItem) @observable s = new SomeItem 14 @persist('map', SomeItem) @observable m = observable.map<SomeItem>({}) 15 @persist('list', SomeItem) @observable l = [] 16} 17 18const hydrate = create({ 19 storage: localForage, // or AsyncStorage in react-native. 20 // default: localStorage 21 jsonify: false // if you use AsyncStorage, here shoud be true 22 // default: true 23}) 24 25// create the state 26export const someStore = new SomeStore() 27hydrate('some', someStore).then(() => console.log('someStore has been hydrated')) 28
without decorators
1const data = observable({ 2 title: 'no decorator', 3 someObject: { 4 a: 1, 5 b: 'b', 6 }, 7 someArray: [{ 8 c: 1, 9 d: 'd' 10 }] 11}) 12const schema = { 13 title: true, 14 someObject: { 15 type: 'object', 16 schema: { 17 a: true, 18 b: true 19 } 20 }, 21 someArray: { 22 type: 'list', 23 schema: { 24 c: true, 25 d: true 26 } 27 } 28} 29export const someStore = persist(schema)(data) 30hydrate('some', someStore).then(() => console.log('someStore has been hydrated'))
with initial state
1const initialState = window.__STATE__.some || { 2 obj: { a: 2, b: 1 } 3} 4export const someStore = new SomeStore() 5 6hydrate('some', someStore, initialState) 7 .then(() => console.log('some hydrated'))
re-hydration
1const result = hydrate('some', someStore, initialState) 2const rehydrate = result.rehydrate 3result.then(() => console.log('some hydrated')) 4 5setTimeout(() => { 6 rehydrate().then(() => console.log('rehydrated')) 7}, 3000)
persist(schema)(object)
'object' | 'list' | 'map'
or a structured schema object.create(config)
hydrate(key, store, initialState?, customArgs?)
IHydrateResult
extends Promise
No vulnerabilities found.
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
Found 4/26 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More