webext-redux
webext-redux copied to clipboard
Change store through background.js
I have a situation whereby I use redux store to store a "loading" status.
User clicks a button on content script which triggers a dispatch to set loading to true, and this starts the background.js off performing API calls.
The issue I have, is if the user closes off the page where the content script is, and the API calls finish, the content script cannot trigger a dispatch to set loading to false, therefore the content script is stuck in loading.
Is it possible to trigger the dispatch from the background script?
you're wrapping the store on background, and then you able use it as simple redux store. for example
const store = createStore(reducers, initialState, middlewares);
wrapStore(store, { portName: 'somePortName' });
store.dispatch(someAction());