How to use storejs - 4 common examples

To help you get started, we’ve selected a few storejs 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 fygethub / react-demo-storybook / src / redux / reducer.js View on Github external
export const chaptersList = (state = {}, action) => {
    switch (action.type){
        case ADD_CHAPTERS_LIST:{
            let focusBooks = storejs.get("focusBooks") || [];
            focusBooks.push()
            return action.chapters;
        }
        default:
            return state;
    }
}
github fygethub / react-demo-storybook / src / redux / reducer.js View on Github external
export const historyList = (state = [], action = '') => {
    var historyListArr = storejs.get("historyListArr") || [];
    switch (action.type){
        case ADD_SEARCH_HISTORY:
            //添加搜索记录缓存

            if(action.bookName === '' || !action.bookName){
                if(state.length === 0){
                    return historyListArr;
                }
                return state;
            }
            if(state.length >= 1){
               let has = isInArr(state,[action.bookName]);
                if(has){
                    return state;
                }
            }
github fygethub / react-demo-storybook / src / redux / reducer.js View on Github external
//添加搜索记录缓存

            if(action.bookName === '' || !action.bookName){
                if(state.length === 0){
                    return historyListArr;
                }
                return state;
            }
            if(state.length >= 1){
               let has = isInArr(state,[action.bookName]);
                if(has){
                    return state;
                }
            }
            historyListArr.push(action.bookName);
            storejs.set('historyListArr',historyListArr);
            return historyListArr;
        case REMOVE_SEARCH_HISTORY:
            if(state.length >= 1 && action !== ''){
                //移除缓存记录
                historyListArr.splice(historyListArr.indexOf(action.bookName),1);
                storejs.set('historyListArr',historyListArr);
                let arr = [].concat(state.filter((name) => name !== action.bookName));
                return arr;
            }
            return state;
        default:
            return state;

    }
}
github fygethub / react-demo-storybook / src / redux / reducer.js View on Github external
export const readDetail = (state = {}, action) => {
    switch (action.type){
        case ADD_READ_DETAIL:
            action.readObj && storejs.set('readDetail', action.readObj);
            return action.readObj.chapter;
        default:
            return state;
    }
}

storejs

Local storage localstorage package provides a simple API

MIT
Latest version published 7 months ago

Package Health Score

58 / 100
Full package analysis

Popular storejs functions