Why must must ngrx / redux effects return actions? Is using a noop action like elm considered bad practice?

By default, an ngrx/effect dispatches an action. If you want an effect to be ‘fire-and-forget’, all you need to do is add {dispatch: false} as an argument to the @Effects() decorator. From the @ngrx/effects docs: Observables decorated with the @Effect() decorator are expected to be a stream of actions to be dispatched. Pass { dispatch: … Read more

How to wait for 2 Actions in @ngrx/effects

I am new to RXJS but what about this. You can remove {dispatch: false} if you change the tap to a switchMap. @Effect({dispatch: false}) public waitForActions(): Observable<any> { const waitFor: string[] = [ SomeAction.EVENT_1, SomeAction.EVENT_2, SomeAction.EVENT_3, ]; return this._actions$ .pipe( ofType(…waitFor), distinct((action: IAction<any>) => action.type), bufferCount(waitFor.length), tap(console.log), ); }

Catch error in combined pipe of pipeable rxjs operators

After refactoring you moved map out of switchMap projection, so any error will close the outer stream. To keep both streams equivalent, you need to use pipe in the projection itself like that: import { EMPTY } from ‘rxjs’; // … @Effect() loadData$ = this.actions$ .ofType(LOAD_DATA) .pipe( map((action: LoadData) => action.payload), withLatestFrom(this.store.select(getCultureCode)), switchMap(([payload, cultureCode]) => … Read more

techhipbettruvabetnorabahisbahis forumu