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


TypeScript Subscriber.create方法代碼示例

本文整理匯總了TypeScript中rxjs/Rx.Subscriber.create方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Subscriber.create方法的具體用法?TypeScript Subscriber.create怎麽用?TypeScript Subscriber.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rxjs/Rx.Subscriber的用法示例。


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

示例1: watchPhoto

  watchPhoto(photoId: number): Observable<any> {
    let openSubscriber = Subscriber.create(
      () => this.webSocket.sendPhotoMessage({photoId: photoId}));

    return this.webSocket.createObservableSocketWithSubscriber('ws://localhost:8000', openSubscriber)
      .map(message => JSON.parse(message));
  }
開發者ID:tomekb82,項目名稱:kursAngular2,代碼行數:7,代碼來源:message-service.ts

示例2: watchProduct

  watchProduct(productId: number): Observable<any> {
    let openSubscriber = Subscriber.create(
      () => this.webSocket.send({productId: productId}));

    return this.webSocket.createObservableSocket('ws://localhost:8000', openSubscriber)
      .map(message => JSON.parse(message));
  }
開發者ID:centaure,項目名稱:angular2typescript,代碼行數:7,代碼來源:bid-service.ts

示例3: it

    it('should observe for complete Notification', () => {
      let observed = false;
      const n = Notification.createComplete();
      const observer = Rx.Subscriber.create((x: any) => {
        throw 'should not be called';
      }, (err: any) => {
        throw 'should not be called';
      }, () => {
        observed = true;
      });

      n.observe(observer);
      expect(observed).to.be.true;
    });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:14,代碼來源:Notification-spec.ts

示例4: it

  it('should be possible to unsubscribe in the middle of the iteration', (done) => {
    const expected = [10, 20, 30];

    const subscriber = Rx.Subscriber.create(
      (x) => {
        expect(x).to.equal(expected.shift());
        if (x === 30) {
          subscriber.unsubscribe();
          done();
        }
      }, (x) => {
        done(new Error('should not be called'));
      }, () => {
        done(new Error('should not be called'));
      }
    );

    fromIterable([10, 20, 30, 40, 50, 60], undefined).subscribe(subscriber);
  });
開發者ID:deanius,項目名稱:RxJS,代碼行數:19,代碼來源:IteratorObservable-spec.ts

示例5: fromIterable

  'but is unsubscribed early', (done) => {
    const expected = [10, 20, 30, 40];

    const source = fromIterable(
      [10, 20, 30, 40],
      Rx.Scheduler.queue
    );

    const subscriber = Rx.Subscriber.create(
      (x) => {
        expect(x).to.equal(expected.shift());
        if (x === 30) {
          subscriber.unsubscribe();
          done();
        }
      }, (x) => {
        done(new Error('should not be called'));
      }, () => {
        done(new Error('should not be called'));
      });

    source.subscribe(subscriber);
  });
開發者ID:deanius,項目名稱:RxJS,代碼行數:23,代碼來源:IteratorObservable-spec.ts


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