Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Effect() route$ = actions$
- .ofType(ACTION_A)
- .switchMap(() => this._store.let(getCapabilities)
- .filter(capabilities => !isOutOfDate(capabilities))
- .take(1)
- )
- .map( do some stuff );
- // Selector function that causes excess observable emits
- export const getCapabilities =
- compose(fromLocations.currentLocationLookup(fromLocations.getCapabilities), fromRoot.getLocations);
- // Selector function works as expected
- export const getCapabilitiesWorking = function (state$: Observable<AppState>): Observable<Capability> {
- return state$
- .let(fromRoot.getLocations)
- .map(l => l.capabilitiesByLocation[l.currentId]);
- };
- // fromLocations
- // -------------
- export function getCapabilities(state$: Observable<LocationsState>): Observable<{ [id: string]: Capability }> {
- return state$.map(s => s.capabilitiesByLocation);
- }
- // Find the value in 'collection' corresponding to the current location
- export function currentLocationLookup<T>(
- collection: (state$: Observable<LocationsState>) => Observable<{ [id: string]: T }>
- ): (state$: Observable<LocationsState>) => Observable<T> {
- return (state$: Observable<LocationsState>): Observable<T> => {
- return Observable.combineLatest(
- state$.let(getCurrentLocation),
- state$.let(collection),
- (locId, map) => map[locId]
- );
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement