Skip to content

preserve Symbol(observable) when connecting the store #129

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

Closed
wants to merge 1 commit into from

Conversation

gseerden
Copy link

I'm migrating an AngularJS app to Angular. The idea is to have ng-redux and ng2-redux share the same store.

This is how I bootstrap my Angular app:

export class AppModule {
  constructor(ngRedux: NgRedux<IAppState>, upgrade: UpgradeModule) {
    upgrade.bootstrap(document.body, [ng1Module]);
    ngRedux.provideStore(upgrade.$injector.get('$ngRedux'));
  }
}

But the I get TypeError: object is not observable.

The object created by Redux's createStore has a key of Symbol(observable). But ng-redux's provider looses that key when connecting the store.

The aim of this pull request is to preserve the object created by Redux and augment it with the connect property.

the object created by redux createStore has a key of Symbol(observable). $ngRedux's provider looses that key when connecting the store. As a result, we can't use $ngRedux's store in ng2Redux's provideStore. angular-redux/store#256
@@ -78,7 +78,8 @@ export default function ngReduxProvider() {
? applyMiddleware(...resolvedMiddleware)(finalCreateStore)(_reducer, _initialState)
: applyMiddleware(...resolvedMiddleware)(finalCreateStore)(_reducer);

return assign({}, store, { connect: Connector(store) });
store.connect = Connector(store);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like _.assign does not copy over Symbols. Can you change this PR to remove assign and use Object.assign instead? That should copy it over while keeping everything immutable as before.

@AntJanus
Copy link
Collaborator

AntJanus commented Aug 3, 2017

I'll go ahead and close this out due to inactivity. Thanks for bringing attention to the issue!

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

Successfully merging this pull request may close these issues.

2 participants