Closed borzovplus closed 7 years ago
The most minimal example of using this would just be
import { electronEnhancer } from 'redux-electron-store';
let store = createStore(reducer, initialState, electronEnhancer());
The example in my Readme, in a bit of a confusing fashion, had an example of using a filter included in its "Usage" example, which might've been why you had your issue. I've updated it to be more clear and only mention the filter in the Filters section.
Based on https://github.com/electron/electron-quick-start
// store.js
const { createStore } = require('redux');
const { electronEnhancer } = require('redux-electron-store');
const counter = (state, action) =>
action.type === 'INCREMENT' ? {count: state.counter + 1} : state;
let store = createStore(counter, {count: 0}, electronEnhancer());
store.subscribe(() => console.log(store.getState()));
module.exports = store;
// renderer.js
const store = require('./store');
store.dispatch({type: 'INCREMENT'});
// main.js
// ... all the setup code in electron-quick-start's main.js
const store = require('./store');
setTimeout(() => store.dispatch({type: 'INCREMENT'}), 3000);
the module store.js must be the same for render and main ?
They should be using the same root reducer
But the render and main processes should have a different reducer and actions in my project.. Thank you. I found how to do this without using this lib.
I'm copied code from readme to my project (create store). Please help me to understand why actions from render to main process forwarded, BUT actions from main to render NOT. Could you show a simple example of working code ?