當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。