How to use mobx-persist - 10 common examples

To help you get started, we’ve selected a few mobx-persist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dotnetcore / WTM / demo / WalkingTec.Mvvm.ReactDemo / ClientApp / src / global.config.tsx View on Github external
import ImgLogo from 'assets/img/logo.png';
import ImgUser from 'assets/img/user.png';
import { configure, observable } from 'mobx';
import { create, persist } from 'mobx-persist';
import moment from 'moment';
import 'moment/locale/zh-cn';
import "./global.less";
// 日期中文
moment.locale('zh-cn');
// mobx 严格模式 https://cn.mobx.js.org/refguide/api.html
configure({ enforceActions: "observed" });
notification.config({
    duration: 3,
    top: 60
});
const hydrate = create({
    storage: window.localStorage,   // 存储的对象
    jsonify: true, // 格式化 json
    debounce: 1000,
});
// 环境变量 开发 模型
const development = process.env.NODE_ENV === "development"
class ConfigStore {
    constructor() {
        hydrate('WTM_GlobalConfig', this)
            // post hydration
            .then(() => console.log('some WTM_GlobalConfig', { ...this }))
    }
    buildTime = process.env.REACT_APP_TIME;
    /**
    * 开发环境
    */
github dotnetcore / WTM / demo / WalkingTec.Mvvm.ReactDemo / ClientApp / src / global.config.tsx View on Github external
import ImgLogo from 'assets/img/logo.png';
import ImgUser from 'assets/img/user.png';
import { configure, observable } from 'mobx';
import { create, persist } from 'mobx-persist';
import moment from 'moment';
import 'moment/locale/zh-cn';
import "./global.less";
// 日期中文
moment.locale('zh-cn');
// mobx 严格模式 https://cn.mobx.js.org/refguide/api.html
configure({ enforceActions: "observed" });
notification.config({
    duration: 3,
    top: 60
});
const hydrate = create({
    storage: window.localStorage,   // 存储的对象
    jsonify: true, // 格式化 json
    debounce: 1000,
});
// 环境变量 开发 模型
const development = process.env.NODE_ENV === "development"
class ConfigStore {
    constructor() {
        hydrate('WTM_GlobalConfig', this)
            // post hydration
            .then(() => console.log('some WTM_GlobalConfig', { ...this }))
    }
    buildTime = process.env.REACT_APP_TIME;
    /**
    * 开发环境
    */
github dotnetcore / WTM / demo / WalkingTec.Mvvm.ReactDemo / ClientApp / src / app / layout / antdPro / TabsPages / index.tsx View on Github external
import { Icon, Tabs } from 'antd';
import LayoutSpin from "components/other/LayoutSpin";
import lodash from 'lodash';
import { action, observable, runInAction, toJS } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { Item, Menu, MenuProvider } from 'react-contexify';
import { matchRoutes } from 'react-router-config';
import { fromEvent } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import Store from 'store/index';
import './index.less';
import { create, persist } from 'mobx-persist';
import { FormattedMessage } from 'react-intl';
const hydrate = create({
    storage: window.localStorage,   // 存储的对象
    jsonify: true, // 格式化 json
    debounce: 1000,
});
/**
 * tabs 页面布局
 */
export default class App extends React.Component {
    render() {
        return 
    }
}
@observer
class TabsPages extends React.Component {
    TabsPagesStore = new TabsPagesStore(this.props.route.routes);
    componentDidMount() {
github dotnetcore / WTM / demo / WalkingTec.Mvvm.ReactDemo / ClientApp / src / store / system / user.ts View on Github external
/**
 * @author 冷 (https://github.com/LengYXin)
 * @email lengyingxin8966@gmail.com
 * @create date 2018-09-12 18:52:54
 * @modify date 2018-09-12 18:52:54
 * @desc [description]
*/
import Request from 'utils/Request';
import lodash from 'lodash';
import { action, observable, runInAction } from "mobx";
import { create, persist } from 'mobx-persist';
import Menu from './menu'
import globalConfig from 'global.config';
const hydrate = create({
    storage: window.localStorage,   // or AsyncStorage in react-native.
    jsonify: true,  // if you use AsyncStorage, here shoud be true
    debounce: 1000,
})
class Store {
    constructor() {
        hydrate(`__User`, this).then(() => {
            this.CheckLogin()
        })
    }
    @observable loding = true;
    @observable isLogin = false;
    // 用户信息
    @persist("object")
    @observable UserInfo: any = {};
    /** 操作接口数组 */
github iran-react-community / todo-list / src / state / index.js View on Github external
constructor() {
		this.todoListStore = new todoListStore(this);

		// Mobx Persist data [into localStorage by default]
		const hydratedTodoList = create();
		hydratedTodoList("todoList", this.todoListStore);
	}
github FiberJW / pul / stores / EventStore.js View on Github external
@action hydrate = () => {
    const pour = create({
      storage: AsyncStorage
    });

    Object.keys(this).forEach(key => {
      pour(key, this);
    });
  };
}
github FiberJW / pul / stores / UIStore.js View on Github external
@action hydrate = () => {
    const pour = create({
      storage: AsyncStorage
    });

    Object.keys(this).forEach(key => {
      pour(key, this);
    });
  };
}
github FiberJW / pul / stores / TrexStore.js View on Github external
@action hydrate = () => {
    const pour = create({
      storage: AsyncStorage
    });

    Object.keys(this).forEach(key => {
      pour(key, this);
    });
  };
github FiberJW / pul / stores / AuthStore.js View on Github external
@action hydrate = () => {
    const pour = create({
      storage: AsyncStorage
    });

    Object.keys(this).forEach(key => {
      pour(key, this);
    });
  };
github borgfriend / typescript-react-mobx-example / src / stores / index.ts View on Github external
import { MobxStore } from "./mobxStore";
import { create } from "mobx-persist";

interface Stores {
    [key: string]: any;
}

export const stores: Stores = {
    mobxStore: new MobxStore()
}

const hydrate = create({
    storage: localStorage,
    jsonify: true
});

Object.keys(stores).map((val) => hydrate(val, stores[val]))

mobx-persist

create and persist mobx stores

MIT
Latest version published 7 years ago

Package Health Score

48 / 100
Full package analysis

Popular mobx-persist functions