Gathering detailed insights and metrics for mobx-persist-sync
Gathering detailed insights and metrics for mobx-persist-sync
Gathering detailed insights and metrics for mobx-persist-sync
Gathering detailed insights and metrics for mobx-persist-sync
npm install mobx-persist-sync
Typescript
Module System
Node Version
NPM Version
TypeScript (61.89%)
JavaScript (36.8%)
HTML (1.31%)
Built with Next.js • Fully responsive • SEO optimized • Open source ready
Total Downloads
469
Last Day
2
Last Week
10
Last Month
31
Last Year
347
MIT License
560 Stars
109 Commits
61 Forks
10 Watchers
2 Branches
7 Contributors
Updated on Jun 14, 2025
Latest Version
0.4.4
Package Id
mobx-persist-sync@0.4.4
Unpacked Size
13.41 kB
Size
4.74 kB
File Count
13
NPM Version
6.14.18
Node Version
14.21.3
Published on
Nov 04, 2024
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
11.1%
10
Compared to previous week
Last Month
244.4%
31
Compared to previous month
Last Year
184.4%
347
Compared to previous year
$ npm install mobx-persist-sync --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 MMKV in react-native. 20 // default: localStorage 21 jsonify: false // if you use MMKV, here shoud be true 22 // default: true 23}) 24 25// create the state 26export const someStore = new SomeStore() 27hydrate('some', someStore); 28console.log('someStore has been hydrated') 29
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); 31console.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 3console.log('some hydrated') 4 5setTimeout(() => { 6 rehydrate(); 7 console.log('rehydrated') 8}, 3000)
persist(schema)(object)
'object' | 'list' | 'map'
or a structured schema object.create(config)
hydrate(key, store, initialState?, customArgs?)
IHydrateResult
extends function
No vulnerabilities found.