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

TypeScript Rx.Subscription类代码示例

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

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



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

示例1: Subscription

    return Observable.create(o => {
      const disposables = new Subscription()
      log.debug(
        `Subscribing to topic [${topic}]. Is connected [${this.isConnected}]`
      )

      if (!this.isConnected) {
        o.error(
          new Error(
            `Session not connected, can\'t subscribe to topic [${topic}]`
          )
        )
        return disposables
      }

      let subscription
      this.autobahn.session
        .subscribe(topic, (response: Array<any>) => {
          this.logResponse(topic, response)
          o.next(response[0])
        })
        .then(
          sub => {
            // subscription succeeded, subscription is an instance of autobahn.Subscription
            log.verbose(`subscription acked on topic [${topic}]`)
            subscription = sub
          },
          (error: Error) => {
            // subscription failed, error is an instance of autobahn.Error
            log.error(`Error on topic ${topic}`, error)
            o.error(error)
          }
        )

      disposables.add(
        new Subscription(() => {
          if (!subscription) {
            return
          }
          try {
            this.autobahn.session
              .unsubscribe(subscription)
              .then(
                gone =>
                  log.verbose(`Successfully unsubscribing from topic ${topic}`),
                err => log.error(`Error unsubscribing from topic ${topic}`, err)
              )
          } catch (err) {
            log.error(`Error thrown unsubscribing from topic ${topic}`, err)
          }
        })
      )
      return disposables
    })
开发者ID:carlosrfernandez,项目名称:ReactiveTraderCloud,代码行数:54,代码来源:connection.ts


示例2: ngOnDestroy

 ngOnDestroy()
 {
    const me = this.constructor.name + '.ngOnDestroy(): ';
    console.log( me);
    if (this._currentClusterSubscription)
       this._currentClusterSubscription.unsubscribe();
 }
开发者ID:JohnL4,项目名称:Diaspora,代码行数:7,代码来源:cluster-details.component.ts


示例3:

 this.taskListService.getUserLists().subscribe((taskListsObservable) => {
   if (this.taskListsSubscription != null) {
     this.taskListsSubscription.unsubscribe();
   }
   this.taskListsSubscription =
       taskListsObservable.subscribe((taskLists) => { this.taskLists = taskLists; });
 });
开发者ID:hanaum,项目名称:choose_to_go,代码行数:7,代码来源:userListView.component.ts


示例4: removePreLoader

  private removePreLoader() {
    if(document) {
      let $body = document.body;
      let preloader = document.getElementById('preloader');
      if(preloader) {
        $body.removeChild(preloader);
        this.routeEventsSubscription.unsubscribe();
      }
      $body.classList.remove('loading');

    }
  }
开发者ID:HerringtonDarkholme,项目名称:Deneb,代码行数:12,代码来源:app.component.ts


示例5: add

  add(teardownSrc: TeardownLogic): Subscription {
    let teardown: any = teardownSrc
    if (this.closed) return this
    if (typeof(teardownSrc) === 'function') teardown = new Subscription(teardown)

    if (this.currentSubscription) {
      this.remove(this.currentSubscription)
      this.currentSubscription.unsubscribe()
      this.currentSubscription = null
    }

    super.add(this.currentSubscription = teardown)
    return this
  }
开发者ID:carlosrfernandez,项目名称:ReactiveTraderCloud,代码行数:14,代码来源:serialSubscription.ts


示例6: runPreIFrameTasks

 runPreIFrameTasks() {
     if (this._preIFrameTasks && this._preIFrameTasks.isUnsubscribed) {
         this._preIFrameTasks.unsubscribe();
     }
     this._preIFrameTasks = Observable.timer(0, 60000)
         .concatMap<string>(() => this._http.get('api/token?plaintext=true').retry(5).map<string>(r => r.text()))
         .subscribe(t => this._userService.setToken(t));
 }
开发者ID:rumnha,项目名称:AzureFunctionsPortal,代码行数:8,代码来源:background-tasks.service.ts


示例7:

 (navTabName: string) => {
     if( navTabName !== name && !this.vhostTreeSubs.isUnsubscribed ) { // 플레이어 탭이 아닐 때
         this.vhostTreeSubs.unsubscribe();
         this.stopAllPlayers();
     }
     else {
         this.subscribeVhostTree();
         this.reloadAllPlayers();
     }
 }
开发者ID:BaeHongil,项目名称:VMS,代码行数:10,代码来源:players.component.ts


示例8: setTimeout

                setTimeout(() => {
                    if (value.indexOf("/") !== -1) {
                        o.next({ noSlashAsync: true });
                    } else {
                        o.next(null);
                    }

                    // wait for bug update. maybe at final release.
                    console.log(v);

                    o.complete();
                    s.unsubscribe();
                }, 1000);
开发者ID:zhaowenjunzz,项目名称:StudyAngular2,代码行数:13,代码来源:custom-validators.ts


示例9: createExecuteTradeResponse

 .subscribe(limitCheckResult => {
   if (limitCheckResult) {
     const request = serviceClient
       .createRequestResponseOperation(
         'executeTrade',
         executeTradeRequest
       )
       .publish()
       .refCount()
     disposables.add(
       Observable.merge(
         request
           .map(dto => {
             const trade = tradeMapper.mapFromTradeDto(dto.Trade)
             log.info(
               `execute response received for: ${executeTradeRequest}. Status: ${trade.status}`,
               dto
             )
             return createExecuteTradeResponse(trade)
           })
           // if we never receive a response, mark request as complete
           .timeout(
             EXECUTION_REQUEST_TIMEOUT_MS,
             Scheduler.asap.schedule(() =>
               createExecuteTradeResponseForError(
                 'Trade execution timeout exceeded',
                 executeTradeRequest
               )
             )
           ),
         // show timeout error if request is taking longer than expected
         Observable.timer(EXECUTION_CLIENT_TIMEOUT_MS)
           .map(() =>
             createExecuteTradeResponseForError(
               'Trade execution timeout exceeded',
               executeTradeRequest
             )
           )
           .takeUntil(request)
       ).subscribe(o)
     )
   } else {
     o.next(
       createExecuteTradeResponseForError(
         'Credit limit exceeded',
         executeTradeRequest
       )
     )
   }
 })
开发者ID:carlosrfernandez,项目名称:ReactiveTraderCloud,代码行数:50,代码来源:executionService.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript Rx.TestScheduler类代码示例发布时间:2022-05-25
下一篇:
TypeScript Rx.Subscriber类代码示例发布时间: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