score:2

import { createStore, combineReducers } from 'redux';
import <all of your other reducers>

const reducers = combineReducers({
    <other reducers here>
});

const finalReducer = (state, action) => {
    const nextState = reducers(state, action);

    //use whatever module you use to write to mongo...
    persistToMongo(nextState);

    return nextState;
};

const store = createStore(finalReducer, undefined);

score:3

import {createStore, combineReducers, applyMiddleware} from 'redux'

const persist = store => next => action => {
  next(action)
  persistData(store.getState())
}

const store = createStore(<reducer>, undefined, applyMiddleware(persist))

Related Query

More Query from same tag