Skip to content
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

Add multiple redux stores support #310

Open
MaximKalinin opened this issue Jun 7, 2021 · 3 comments
Open

Add multiple redux stores support #310

MaximKalinin opened this issue Jun 7, 2021 · 3 comments

Comments

@MaximKalinin
Copy link

Is your feature request related to a problem? Please describe.
The electron-redux has really easy-to-use API that helps a lot when working on electron applications. However, it has some limits in advanced usage. Specifically, support of multiple redux stores.

In most cases, this wouldn't be an issue at all, however, my team faced it when trying to apply microfrontend approach to electron app.

In this case we create multiple store instances and, of course, use electron-redux middleware. Since the module sends all the actions through single channel, redux store gets mixed unpredictably. Also, global.getReduxState function doesn't work as expected.

Describe the solution you'd like
So I would like to have an opportunity to work with different instances of the store.

Ideally, it shouldn't break current API since it is an advanced feature. I was thinking about three ways of realisation:

  1. Transform all the functions to higher order functions that would accept name of the channel and use it later, e.g.:
applyMiddleware(forwardToMain('redux-1'));
getInitialStateRenderer('redux-1')();
replayActionRenderer('redux-1')();
  1. Export a only factory instead that would accept channel name and return all the methods:
import {factory} from 'electron-redux';

const {forwardToMain, getInitialStateRenderer, replayActionRenderer} = factory('redux-1');

applyMiddleware(forwardToMain);
getInitialStateRenderer();
replayActionRenderer();
  1. Adopt all the exposed functions based on arguments to handle both standard and advanced usage:
import {forwardToMain, getInitialStateRenderer, replayActionRenderer} from 'electron-redux';

applyMiddleware(forwardToMain); // this would work
applyMiddleware(forwardToMain('redux-1')); // this would also work

Describe alternatives you've considered
I already used myself the first approach in my fork since it's the easiest to implement.

I also understand that for most of the use cases it makes no sense to implement this logic so it's fine for me to keep a fork for this specific case only.

@matmalkowski
Copy link
Collaborator

matmalkowski commented Jun 7, 2021

Hi, named stores could become a thing in v2, but we don't plan to add any support for them in v1 anymore

@MaximKalinin
Copy link
Author

Perfect!
Let me know if you would like me to help, otherwise the issue can be considered closed.

@uxigene
Copy link

uxigene commented Mar 2, 2023

Hi, named stores could become a thing in v2, but we don't plan to add any support for them in v1 anymore

Is it still not a thing? Could you please share some info about this feature request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants