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

single store with Multi app #128

Closed
BhaskaranR opened this issue Apr 17, 2017 · 3 comments
Closed

single store with Multi app #128

BhaskaranR opened this issue Apr 17, 2017 · 3 comments

Comments

@BhaskaranR
Copy link

This is more a question than issue. we have a angular multiple app running in a liferay portal. I would want to create a single store that would be share across multiple angular apps. How can I use ngredux to a achieve this?
thanks.

@floriangosse
Copy link

I think you're looking for a feature which will be implemented for version 4.0.0:

implement provideStore functionality (...) – #164

@AntJanus
Copy link
Collaborator

The development on this has definitely stalled a bit (if only I had infinite time on my hands!). But here are a few things you can do:

  1. if you're running multiple angular applications on a single page, create a separate AngularJS module that gets injected into all the apps
  2. create a Redux store and at runtime, inject it into ng-redux using an enhancer. As long as all your redux middleware and reducers are available together immediately, this should be pretty straightforward.

I use the second approach in an AngularJS/Angular app that shares state. Basically it looks like this:

const myStore = createStore(combineReducers({ foo, bar }), initialState, applyMiddleware(thunkMiddleware);

export function sharedReduxEnhancer(createStore) {
  return () => {
     return myStore;
  };
};

And then you use the sharedReduxEnhancer in your Redux setup. What that will do is basically throw away ng-redux's store, and replace it with the shared one. So far, the only bugs that come up are related to trying to add special middleware or functionality only in the AngularJS side or only in the Angular side; however, if you can share behavior between your apps, this shouldn't be a problem.

@AntJanus
Copy link
Collaborator

AntJanus commented Jan 8, 2018

I'm gonna close this since it's a duplicate of #19. It's slated for 4.0.0 release.

@AntJanus AntJanus closed this as completed Jan 8, 2018
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