ngrx / store

RxJS powered state management for Angular applications, inspired by Redux
MIT License
3.9k stars 310 forks source link

provideStore doesn't work - Plunkr and ReadMe do not agree #108

Closed jkyoutsey closed 8 years ago

jkyoutsey commented 8 years ago

npm@2.14.7 node 4.2.1 Chrome latest angular2 beta 17

provideStore({SearchCounterReducer}, {counter: 0}) Results in: angular2-polyfills.js:349 Error: Error: Invalid provider - only instances of Provider and Type are allowed, got: [object Object](…)

And the Plunkr does this instead: provide(Store, {useValue: enhanced(combineReducers({todos, visibilityFilter})) }) Now, enhanced is a variable that is an instrumented version of createStore(). However createStore isn't exported from @ngrx/store. So, it's unclear what my provide SHOULD look like...

Using the Plunkr for main.ts and doing this.store.dispatch() in my class throws dispatch is not a function. Which appears to be because I should be calling createStore(combineReducers(...)) in my provide.

All of the EventEmitter stuff in the Plunker is quite the departure from the ReadMe.md. The ReadMe shows the Redux API way of doing things (i.e. dispatch).

So, what am I missing?


@angular/core was really throwing me off. npm installed a soft dependency on angular2 rc 0. I can't move my whole project right now, so I had to map it to my version of ng2. Then it would compile with (after a little digging): provideStore(combineReducers(SearchCounterReducer), {counter:0})

abdulhaq-e commented 8 years ago

Have a look at this https://github.com/ngrx/store/issues/106 , it maybe the same.

jkyoutsey commented 8 years ago

@abdulhaq-e Yes, I was just editing my comment to that effect! Thanks!