-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Aliases Easy by Following electron-redux's Lead? #141
Comments
@vhmth Agreed - this is a great idea! I'm wondering what the best implementation structure would look like. Ideally we want this to be configured into a store so that we continue to same composability paradigm we've been using before (you can have multiple proxy or background stores without any complication). Creating the alias action is easy, and the storage is easy (we can just store internally exactly how we are now). The question is how we attach to a store. The middleware was nice because it was transparent in what it was doing and just used redux's store api. I can see us doing it through the |
So the middleware way being turning something like this: // background.js
import { applyMiddleware, createStore } from 'redux';
import { alias, wrapStore } from 'react-chrome-redux';
const aliases = {
// this key is the name of the action to proxy, the value is the action
// creator that gets executed when the proxied action is received in the
// background
'user-clicked-alias': () => {
// this call can only be made in the background script
chrome.notifications.create(...);
};
};
const store = createStore(rootReducer,
applyMiddleware(
alias(aliases)
)
); Into something like this: // background.js
import { applyMiddleware, createStore } from 'redux';
import { aliases, wrapStore } from 'react-chrome-redux';
aliases.createAlias("user-clicked-alias", () => {
// this call can only be made in the background script
chrome.notifications.create(...);
});
const store = createStore(rootReducer,
applyMiddleware(
aliases
)
); |
Somewhat. I was thinking we take it a step further and return an action creator that can be called either on the background or content script and will always execute in the background. Something like this:
Now you can use |
While this might not be as much of a problem in Chrome extensions, something worth considering is the potential issue of having action creators defined both in the background script and the content script(s). See klarna/electron-redux#92 for more detail. Essentially we need the ability to declare and define aliased actions separately somehow, but hopefully not with duplicated code. |
https://www.useloom.com/share/d3e482bbc3354bd0b1c1b6fadb5f8fd6
#131 (comment)
The text was updated successfully, but these errors were encountered: