A selector is going to have something like this in it, and not just this. There will be other import statements too.
import { createSelector } from '@ngrx/store';
export const getBase = function (state: DataContext) {
return state && state.base ? state.base : new BaseModel();
};
export const getStuff = createSelector(
getBase,
(x: BaseModel) => {
return x.Whatever;
}
);
\node_modules\@ngrx\store\src\selector.d.ts is where one will find the createSelector function. Anyhow, an example of using .take(1) with this stuff would be:
return this.store.select(getStuff).take(1);
This suggests that you may chain other things like a .subscribe off of a .first() which could be used in lieu of .take(1) and then catch an error. Obviously the advantage with .take is you could take more than the first item. You cannot chain beyond it however.
No comments:
Post a Comment