当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ReplaySubject.subscribe方法代码示例

本文整理汇总了TypeScript中rxjs.ReplaySubject.subscribe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ReplaySubject.subscribe方法的具体用法?TypeScript ReplaySubject.subscribe怎么用?TypeScript ReplaySubject.subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rxjs.ReplaySubject的用法示例。


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

示例1: inject

 inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
   const responses: Response[] = [sampleResponse1, sampleResponse2];
   backend.connections.subscribe((c: MockConnection) => c.mockRespond(responses.shift() !));
   const responseObservable: ReplaySubject<Response> =
       backend.createConnection(sampleRequest1).response;
   responseObservable.subscribe(res => expect(res.text()).toBe('response1'));
   responseObservable.subscribe(
       res => expect(res.text()).toBe('response2'), null !, async.done);
 }));
开发者ID:Cammisuli,项目名称:angular,代码行数:9,代码来源:mock_backend_spec.ts

示例2:

 .then(() => {
   this.candidates.subscribe((ic) =>
     this.pc
       .addIceCandidate(ic)
       .catch((err) => log.webrtc(`${this.id}: Failed to add REMOTE Ice Candidate`, err))
   )
 })
开发者ID:openpaas-ng,项目名称:netflux,代码行数:7,代码来源:Remote.ts

示例3: replaySubject

 replaySubject() {
     let replaySubject$ = new ReplaySubject(2); // Buffer 2 values for new subscribers
     interval(300).pipe(
         take(5)
     ).subscribe(replaySubject$);
     replaySubject$.subscribe(val => console.log(`Replay subject 1: ${val}`)); // 0, 1, 2, 3, 4
     setTimeout(() => {
         replaySubject$.subscribe(val => console.log(`Replay subject 2: ${val}`)); // 1, 2, 3, 4
     }, 1000);
 }
开发者ID:mr-Deviant,项目名称:sandbox,代码行数:10,代码来源:subjects.component.ts

示例4: shareReplay3

  shareReplay3() {
    //  simulate url change with subject
    const routeEnd = new Subject<{data: any, url: string}>();

    //  instead of using shareReplay, use ReplaySubject
    const shareWithReplay = new ReplaySubject();

    //  grab url and share with subscribers
    const lastUrl = routeEnd.pipe(
      pluck('url')
    )
    .subscribe(val => shareWithReplay.next(val));

    //  simulate route change
    routeEnd.next({data: {}, url: 'my-path'});

    //  subscribe to ReplaySubject instead
    //  logged: 'my path'
    shareWithReplay.subscribe(console.log);
  }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:20,代码来源:connectable.service.ts

示例5: setTimeout

setTimeout(() => subject$.subscribe((x) => console.log("First: " + x)), 3000);
开发者ID:chrigu,项目名称:rxjs-experiments,代码行数:1,代码来源:replaySubject.ts

示例6: setTimeout

 setTimeout(() => {
     replaySubject$.subscribe(val => console.log(`Replay subject 2: ${val}`)); // 1, 2, 3, 4
 }, 1000);
开发者ID:mr-Deviant,项目名称:sandbox,代码行数:3,代码来源:subjects.component.ts

示例7: constructor

 constructor() {
   this.saleReplaySubject = new ReplaySubject<Sale>(1);
   this.saleReplaySubject.subscribe(sale => console.warn(sale));
 }
开发者ID:sergiocosus,项目名称:ventamatic.frontend,代码行数:4,代码来源:ticket.service.ts


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