0.0.5 • Published 5 years ago

redux-auto-local-storage v0.0.5

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Use

兼容 immutable 和普通 js 对象, 读取 store.getState()中的值,如果改变就本地持久化

import reduxAutoLocalStorage from "redux-auto-local-storage";
reduxAutoLocalStorage(store, "local-name", ["user", "data"]);

如果未使用 combineReducers, 添加一个 reducer 处理:

function reducer(state, action){
    if (action.type === "all_auto_local_storage") {
       return {...state, ...action.payload};
    }
}

如果使用了 combineReducers, 为每个需要本地化的subReducer添加一个 reducer 处理:

// userReducer
function user(state, action){
    // type 等于 state的键加'_auto_local_storage'
    if (action.type === "user_auto_local_storage") {
       return {...state, ...action.payload};
    }
}

reduxAutoLocalStorage 会在读取到属性时进行本地化

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago