当前位置: 首页>>代码示例>>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;未经允许,请勿转载。