• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript operators.filter函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中rxjs/operators.filter函数的典型用法代码示例。如果您正苦于以下问题:TypeScript filter函数的具体用法?TypeScript filter怎么用?TypeScript filter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了filter函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: resolve

 resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<ICartaoCredito> {
   const id = route.params['id'] ? route.params['id'] : null;
   if (id) {
     return this.service.find(id).pipe(
       filter((response: HttpResponse<CartaoCredito>) => response.ok),
       map((cartaoCredito: HttpResponse<CartaoCredito>) => cartaoCredito.body)
     );
   }
   return of(new CartaoCredito());
 }
开发者ID:jbbfreitas,项目名称:BestMeal,代码行数:10,代码来源:cartao-credito.route.ts


示例2: allocate

  async allocate(binderOpts: BinderOptions): Promise<ServerConfig> {
    let original = this.get(binderOpts);

    switch (original.type) {
      case UP:
        // cache hit with an UP server, check if it's really up
        const isUp = await this.checkUp(original);
        if (isUp) {
          // It is so we can plow forward
          return original.config;
        }
        // Otherwise we need to make a new server
        break;
      case NOHOST:
        // Definitely need to launch
        break;
      case PROVISIONING:
        // Wait for the provisioning server to get up
        while (original.type !== UP) {
          await sleep(1000);
          // NOTE: Could do coordination here by recording timestamps in the PROVISIONING type
          // At the very least there should come a point we time out at
          original = this.get(binderOpts);
        }

        if (original && original.type === UP) {
          return original.config;
        }
    }

    const host = await binder(binderOpts)
      .pipe(
        tap(x => {
          // Log binder messages to the console for debuggability
          console.log("%c BINDER MESSAGE", "color: rgb(87, 154, 202)");
          console.log(x);
        }),
        filter(msg => msg.phase === "ready"),
        map(msg => makeHost({ endpoint: msg.url, token: msg.token }))
      )
      .toPromise();

    if (
      !host.config ||
      !host.config.endpoint ||
      !host.config.token ||
      !host.config.crossDomain
    ) {
      throw new Error(`Bad host created: ${JSON.stringify(host, null, 2)}`);
    }

    this.set(binderOpts, host);

    return host.config;
  }
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:55,代码来源:host-storage.ts


示例3: ngOnInit

  ngOnInit() {
    const end$ = this.router.events.pipe(
      filter(e => e instanceof NavigationEnd || e instanceof NavigationCancel || e instanceof NavigationError)
    );

    this.progress$ = this.router.events.pipe(
      filter(e => e instanceof NavigationStart), // trigger the emission when a navigation starts
      switchMap(() => merge( // then emit every 500ms, and when the navigation ends or cancels or errors. This delay must
                             // match the transition duration in the .scss file
        timer(0, 500).pipe(
          map(i => 100 - (100 / Math.pow(2, i))), // emit 0 then 50, 75, 87.5, etc.
          takeWhile(i => i < 99.95), // stop because that just triggers change detection with no visual change anymore
          takeUntil(end$), // but stop emitting every 500ms when the navigation ends or cancels or errors
          map(i => ({ value: i }))
        ),
        end$.pipe(first(), map(() => null)) // set back to null when the navigation ends or cancels or errors to hide
                                            // the progress bar
      ))
    );
  }
开发者ID:Ninja-Squad,项目名称:globe42,代码行数:20,代码来源:navigation-progress.component.ts


示例4: watchForRawEvents

 watchForRawEvents(logger: RawEventLogger, topicFilter: string, topicPrefix: string) {
     this.communicationManager
         .observeRaw(this.identity, topicFilter)
         // Note that all published raw messages are dispatched on all raw observables!
         .pipe(filter(([topic]) => topic.startsWith(topicPrefix)))
         .subscribe(([topic, payload]) => {
             logger.count++;
             // Raw values are emitted as tuples of topic name and Uint8Array/Buffer payload
             logger.eventData.push([topic, payload.toString()]);
         });
 }
开发者ID:coatyio,项目名称:coaty-js,代码行数:11,代码来源:communication.mocks.ts


示例5: checkStore

 checkStore(panelId: number, boardId: number): Observable<boolean> {
     return this.store.select(fromStore.getBoardLoaded).pipe(
         tap(loaded  => {
             if (!loaded || !this.hasBoardInStore(boardId)) {
                 this.store.dispatch(new fromStore.LoadBoard({ panelId, boardId }));
             }
         }),
         filter(loaded => loaded),
         take(1)
     );
 }
开发者ID:ArmyMusicOnline,项目名称:ami,代码行数:11,代码来源:board-details.guard.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 => loaded),
     take(1)
   )
 }
开发者ID:CharlieMisner,项目名称:ngrx-store-effects-app,代码行数:11,代码来源:pizzas.guards.ts


示例7: _getDescendants

 /** A helper function to get descendants recursively. */
 protected _getDescendants(descendants: T[], dataNode: T): void {
   descendants.push(dataNode);
   const childrenNodes = this.getChildren(dataNode);
   if (Array.isArray(childrenNodes)) {
     childrenNodes.forEach((child: T) => this._getDescendants(descendants, child));
   } else if (childrenNodes instanceof Observable) {
     childrenNodes.pipe(take(1), filter(Boolean)).subscribe(children => {
       children.forEach((child: T) => this._getDescendants(descendants, child));
     });
   }
 }
开发者ID:Nodarii,项目名称:material2,代码行数:12,代码来源:nested-tree-control.ts


示例8: _observeDiscoverIdentity

 private _observeDiscoverIdentity() {
     this._discoverIdentitySubscription =
         this.communicationManager.observeDiscover(this.identity)
             .pipe(filter(event =>
                 (event.eventData.isDiscoveringTypes &&
                     event.eventData.isCoreTypeCompatible("Component")) ||
                 (event.eventData.isDiscoveringObjectId &&
                     event.eventData.objectId === this.identity.objectId)))
             .subscribe(event =>
                 event.resolve(ResolveEvent.withObject(this.identity, this.identity)));
 }
开发者ID:coatyio,项目名称:coaty-js,代码行数:11,代码来源:controller.ts


示例9: factory

function factory(
  observable: Observable<SubjectPayload<string, any, any>>,
  initialState: number,
) {
  return {
    view: observable.pipe(
      filter(args => args.type === 'test'),
      mapTo(1),
    ),
  };
}
开发者ID:brn,项目名称:react-mvi,代码行数:11,代码来源:prepare.spec.ts


示例10: checkStore

 checkStore(): Observable<boolean> {
   return this.store.select(getUserLoaded).pipe(
     tap(loaded => {
       if (!loaded) {
         this.store.dispatch(new LoadUsers());
       }
     }),
     filter(loaded => loaded),
     take(1)
   );
 }
开发者ID:hisptz,项目名称:scorecard,代码行数:11,代码来源:user.exists.ts



注:本文中的rxjs/operators.filter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript operators.finalize函数代码示例发布时间:2022-05-25
下一篇:
TypeScript operators.expand函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap