當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript operators.tap函數代碼示例

本文整理匯總了TypeScript中rxjs/operators.tap函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript tap函數的具體用法?TypeScript tap怎麽用?TypeScript tap使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了tap函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it(`supports font-awesome imports`, (done) => {
    host.writeMultipleFiles({
      'src/styles.scss': `
        $fa-font-path: "~font-awesome/fonts";
        @import "~font-awesome/scss/font-awesome";
      `,
    });

    const overrides = { extractCss: true, styles: [`src/styles.scss`] };

    runTargetSpec(host, browserTargetSpec, overrides).pipe(
      tap((buildEvent) => expect(buildEvent.success).toBe(true)),
    ).toPromise().then(done, done.fail);
  }, 30000);
開發者ID:rexebin,項目名稱:angular-cli,代碼行數:14,代碼來源:styles_spec_large.ts

示例2: canActivate

  canActivate(
    next: ActivatedRouteSnapshot,
    state: RouterStateSnapshot): Observable<boolean> {

    return this.auth.user$.pipe(
      take(1),
      map(user => ((!user && this.auth.canEdit(user)))),
      tap((canEdit: boolean) => {
        if (!canEdit) {
          console.error('Access denied. Must have permission to EDIT content');
        }
      })
    );
  }
開發者ID:Meistercoach83,項目名稱:sfw,代碼行數:14,代碼來源:can-edit.guard.ts

示例3: intercept

 intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
   return next.handle(request).pipe(
     tap(
       (event: HttpEvent<any>) => {},
       (err: any) => {
         if (err instanceof HttpErrorResponse) {
           if (!(err.status === 401 && (err.message === '' || (err.url && err.url.includes('/api/account'))))) {
             this.eventManager.broadcast({ name: 'bestMealApp.httpError', content: err });
           }
         }
       }
     )
   );
 }
開發者ID:jbbfreitas,項目名稱:BestMeal,代碼行數:14,代碼來源:errorhandler.interceptor.ts

示例4: filter

 ngxsBootstrap<T>(action: T, results: StatesAndDefaults | undefined): void {
   this.internalStateOperations
     .getRootStateOperations()
     .dispatch(action)
     .pipe(
       filter(() => !!results),
       tap(() => this.invokeInit(results!.states)),
       mergeMap(() => this.bootstrapper.appBootstrapped$),
       filter(appBootstrapped => !!appBootstrapped)
     )
     .subscribe(() => {
       this.invokeBootstrap(results!.states);
     });
 }
開發者ID:LucasFrecia,項目名稱:store,代碼行數:14,代碼來源:lifecycle-state-manager.ts

示例5: observe

 observe(() => {
   const {
     job: { id }
   } = createUpdateWithSchedule;
   return updateJob(id, createUpdateWithSchedule).pipe(
     tap(() =>
       expect(mockRequest).toHaveBeenLastCalledWith(expect.anything(), {
         body: JSON.stringify(createUpdateWithSchedule.schedule),
         method: "PUT",
         headers: expect.anything()
       })
     )
   );
 })
開發者ID:dcos,項目名稱:dcos-ui,代碼行數:14,代碼來源:MetronomeClient-test.ts

示例6: checkStore

 checkStore(): Observable<boolean> {
   return this.store.select(fromStore.getPizzasLoaded)
     .pipe(
       tap((loaded) => {
         if (!loaded) {
           this.store.dispatch(new fromStore.LoadPizzas());
         }
       }),
       filter((loaded) => {
         return loaded;
       }),
       take(1)
     )
 }
開發者ID:dereklin,項目名稱:ngrx-store-effects-app,代碼行數:14,代碼來源:pizza-exists.guard.ts

示例7: it

  it('preserves script order', (done) => {
    host.writeMultipleFiles(scripts);

    const overrides = { scripts: getScriptsOption() };

    runTargetSpec(host, browserTargetSpec, overrides).pipe(
      tap((buildEvent) => expect(buildEvent.success).toBe(true)),
      tap(() => {
        const re = new RegExp(
          /.*['"]input-script['"](.|\n|\r)*/.source
          + /['"]zinput-script['"](.|\n|\r)*/.source
          + /['"]finput-script['"](.|\n|\r)*/.source
          + /['"]uinput-script['"](.|\n|\r)*/.source
          + /['"]binput-script['"](.|\n|\r)*/.source
          + /['"]ainput-script['"](.|\n|\r)*/.source
          + /['"]cinput-script['"]/.source,
        );
        const fileName = './dist/scripts.js';
        const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
        expect(content).toMatch(re);
      }),
    ).toPromise().then(done, done.fail);
  }, Timeout.Basic);
開發者ID:fmalcher,項目名稱:angular-cli,代碼行數:23,代碼來源:scripts-array_spec_large.ts

示例8: it

  it('runs watch mode', (done) => {
    const overrides = { watch: true };

    runTargetSpec(host, { project: 'app', target: 'server' }, overrides).pipe(
      tap((buildEvent) => {
        expect(buildEvent.success).toBe(true);

        const fileName = join(outputPath, 'main.js');
        const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
        expect(content).toMatch(/AppServerModuleNgFactory/);
      }),
      take(1),
    ).subscribe(undefined, done.fail, done);
  });
開發者ID:baconwaffles,項目名稱:angular-cli,代碼行數:14,代碼來源:base_spec_large.ts

示例9: canActivate

 canActivate(
   next: ActivatedRouteSnapshot,
   state: RouterStateSnapshot
 ): Observable<boolean> {
   return this.store.select(s => s.environement).pipe(
     map(env => env.uid),
     map(uid => !!uid),
     tap(hasUid => {
       if (!hasUid) {
         this.router.navigate(['/main/caption']);
       }
     })
   );
 }
開發者ID:chgc,項目名稱:stream-tools,代碼行數:14,代碼來源:editable.guard.ts


注:本文中的rxjs/operators.tap函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。