How to use the @ngrx/effects.act function in @ngrx/effects

To help you get started, we’ve selected a few @ngrx/effects examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngrx / platform / modules / effects / spec / act.spec.ts View on Github external
it('should use provided flattening operator', () => {
    const sources$ = hot('  -a--b', genActions('ab'));
    const project = () => cold('v------(w|)', genActions('vw'));
    const error = () => createAction('e')();

    // Merge map starts project streams in parallel
    const expected$ = cold('-v--v---w--w', genActions('vw'));

    const output$ = sources$.pipe(act({ project, error, operator: mergeMap }));

    expect(output$).toBeObservable(expected$);
  });
github ngrx / platform / modules / effects / spec / act.spec.ts View on Github external
it('should flatten projects with concatMap by default', () => {
    const sources$ = hot('  -a--b', genActions('ab'));
    const project = () => cold('v------(w|)', genActions('vw'));
    const error = () => createAction('e')();

    // Even thought source produced actions one right after another, operator
    // wait for the project to complete before handling second source action.
    const expected$ = cold('-v------(wv)---w', genActions('vw'));

    const output$ = sources$.pipe(act(project, error));

    expect(output$).toBeObservable(expected$);
  });
github ngrx / platform / modules / effects / spec / act.spec.ts View on Github external
it('should call project functon', () => {
    const sources$ = hot('-a-b', genActions('ab'));

    const actual$ = new Subject();
    const project = jasmine
      .createSpy('project')
      .and.callFake((...args: [Action, number]) => {
        actual$.next(args);
        return cold('(v|)', genActions('v'));
      });
    const error = () => createAction('e')();

    sources$.pipe(act(project, error)).subscribe();

    expect(actual$).toBeObservable(
      cold('              -a-b', {
        a: [createAction('a')(), 0],
        b: [createAction('b')(), 1],
      })
    );
  });