How to use the rxjs/operators.tap function in rxjs

To help you get started, we’ve selected a few rxjs 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 trufflesuite / drizzle-utils / packages / contract-state-stream / __tests__ / node_env.js View on Github external
web3,
      pollingInterval: 200,
    });

    const returnVal$ = createContractState$({
      newBlock$,
      artifact,
      provider,
    });

    // tap observable to make sure it emitted a "0" and then a "5"
    returnVal$
      .pipe(
        take(2),
        toArray(),
        tap(vals => {
          const twoValues = vals.map(x =>
            x.variables.storedData.value.toString(),
          );
          expect(twoValues).toEqual(["0", "5"]);
          expect(vals[0]).toMatchSnapshot(stateMatcher);
          expect(vals[1]).toMatchSnapshot(stateMatcher);
        }),
        finalize(() => {
          expect.assertions(3);
          done();
        }),
      )
      .subscribe();

    await contractInstance.methods.set(0).send({ from: accounts[0] });
    await contractInstance.methods.set(5).send({ from: accounts[0] });
github elastic / kibana / src / legacy / plugin_discovery / find_plugin_specs.js View on Github external
bufferAllResults,
        map(({ spec, deprecations }) => {
          const isRightVersion = spec.isVersionCompatible(config.get('pkg.version'));
          const enabled = isRightVersion && spec.isEnabled(config);
          return {
            config,
            spec,
            deprecations,
            enabledSpecs: enabled ? [spec] : [],
            disabledSpecs: enabled ? [] : [spec],
            invalidVersionSpecs: isRightVersion ? [] : [spec],
          };
        }),
        // determine which plugins are disabled before actually removing things from the config
        bufferAllResults,
        tap(result => {
          for (const spec of result.disabledSpecs) {
            disableConfigExtension(spec, config);
          }
        })
      )
    )),
    share()
github phucan1108 / letportal / src / web-portal / src / app / modules / portal / modules / render / components / dynamic-list / components / dynamic-list.grid.component.ts View on Github external
// Trigger loading data form sortChange and page event
        if (this.listOptions.enablePagination) {
            this.cd.detectChanges()
            merge(this.sort.sortChange, this.paginator.page)
                .pipe(
                    tap(() => {
                        this.fetchDataQuery = this.getFetchDataQuery();
                        this.fetchData();
                    })
                )
                .subscribe();
        }
        else {
            this.sort.sortChange
                .pipe(
                    tap(() => {
                        this.fetchDataQuery = this.getFetchDataQuery();
                        this.fetchData();
                    })
                )
                .subscribe();
        }
    }
github dynatrace-oss / barista / components / autocomplete / src / autocomplete-trigger.ts View on Github external
private _subscribeToClosingActions(): Subscription {
    const firstStable = this._zone.onStable.asObservable().pipe(take(1));
    const optionChanges = this.autocomplete.options.changes.pipe(
      tap(() => {
        this._positionStrategy.reapplyLastPosition();
      }),
      // Defer emitting to the stream until the next tick, because changing
      // bindings in here will cause "changed after checked" errors.
      delay(0),
    );

    // When the zone is stable initially, and when the option list changes...
    return (
      merge(firstStable, optionChanges)
        .pipe(
          // create a new stream of panelClosingActions, replacing any previous streams
          // that were created, and flatten it so our stream only emits closing events...
          switchMap(optionChange => {
            this._resetActiveItem();
            this.autocomplete._setVisibility();
github sourcegraph / sourcegraph / client / browser / src / shared / components / BlobAnnotator.tsx View on Github external
private getTooltip(target: HTMLElement, ctx: AbsoluteRepoFilePosition): Observable {
        return this.simpleProviderFns.fetchHover(ctx).pipe(
            tap(data => {
                if (isEmptyHover(data)) {
                    // short-cirtuit, no tooltip data
                    return
                }
                target.style.cursor = 'pointer'
                target.classList.add('selection-highlight')
            }),
            map(data => ({ target, ctx, ...data }))
        )
    }
    /**
github bwsw / cloudstack-ui / src / app / reducers / vm / redux / vm.effects.ts View on Github external
private start(vm: VirtualMachine) {
    const notificationId = this.jobsNotificationService.add('NOTIFICATIONS.VM.START_IN_PROGRESS');
    this.update(vm, VmState.InProgress);
    return this.vmService.command(vm, CSCommands.Start).pipe(
      tap(runningVm => {
        const message = 'NOTIFICATIONS.VM.START_DONE';
        this.showNotificationsOnFinish(message, notificationId);
        if (runningVm.password) {
          this.showPasswordDialog(runningVm, 'VM_PASSWORD.PASSWORD_HAS_BEEN_SET');
        }
      }),
      map((newVm: VirtualMachine) => new vmActions.UpdateVM(newVm)),
      catchError((error: Error) => {
        const message = 'NOTIFICATIONS.VM.START_FAILED';
        this.dialogService.showNotificationsOnFail(error, message, notificationId);
        return of(
          new vmActions.VMUpdateError({
            error,
            vm,
            state: VmState.Error,
          }),
github jhipster / jhipster-sample-app-mongodb / src / main / webapp / app / blocks / interceptor / errorhandler.interceptor.ts View on Github external
intercept(request: HttpRequest, next: HttpHandler): Observable> {
    return next.handle(request).pipe(
      tap(null, (err: HttpErrorResponse) => {
        if (!(err.status === 401 && (err.message === '' || (err.url && err.url.includes('api/account'))))) {
          this.eventManager.broadcast(new JhiEventWithContent('jhipsterMongodbSampleApplicationApp.httpError', err));
        }
      })
    );
  }
}
github Squidex / squidex / src / Squidex / app / shared / services / schemas.service.ts View on Github external
public enableField(appName: string, resource: Resource, version: Version): Observable {
        const link = resource._links['enable'];

        const url = this.apiUrl.buildUrl(link.href);

        return HTTP.requestVersioned(this.http, link.method, url, version, {}).pipe(
            map(({ payload }) => {
                return parseSchemaWithDetails(payload.body);
            }),
            tap(() => {
                this.analytics.trackEvent('Schema', 'FieldEnabled', appName);
            }),
            pretifyError('Failed to enable field. Please reload.'));
    }
github GetTerminus / ngx-tools / ngx-tools / jwt / src / jwt-token-managment / guards / defaultTokenRequired.ts View on Github external
public canActivate(): Observable {
    return this.currentLoadState.pipe(
      filter(s => s !== 'uninitialized'),
      withLatestFrom(this.currentToken),
      map(([_, token]) => token.length > 0),
      tap(result => {
        if (!result) {
          this.store.dispatch(new FailedToActivateRoute());
        }
      }),
    );

  }