-
Notifications
You must be signed in to change notification settings - Fork 12
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 observables via select() #12
Conversation
Observables are a key feature for performant large scale angular2 apps. This commits forks the select() function from ngrx/store, so we are able to retrieve a observable for a particular state property.
@micha149 this is an awesome PR and a very welcome addition to the angular2-redux library. BTW, have you seen reduxjs/redux#1632 ? |
@rubyboy oh, didn't see that. I updated the pull request. I could drop 2 lines of code and use |
By the way… sorry for the failing CI build. But I can not figure out whats the problem. Tests passes, no linting errors… only typing problems which are also in a working build on master. Do somebody know what the problem is? |
Sorry it took me a while to merge. I'll update the project now to latest angular+redux and release a new version to NPM |
@micha149 I noticed that the "select" method doesn't work when the dev tools extension is enabled (https://github.com/zalmoxisus/redux-devtools-extension). You can see that by adding the following line into the AppComponent of the example app in the project: appStore.select((state)=>state).subscribe((state)=>console.log(state));
// this won't work. Looking at the object outputted above shows why
appStore.select("counter").subscribe((counter)=>console.log("counter",counter)); You need to have the extension installed (otherwise, it won't enable it) |
Created the following issue so it's tracked properly: #13 |
Currently I am missing the ability to work with observables on the store. This is a nice feature which is currently implemented in ngrx/store, but I like the idea to just wrap the actual redux library. So I implemented the
select()
function from ngrx/strore and this comes with this pull request.The idea is simply call
select()
on the store an pass a key or a selector function which extracts the required informations from the store. The method returns an observable which only emit data if the value, returned by the selector, changes.The ability to pass a selector function enables cool possibilities like passing memoized selector functions from reselect: