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


TypeScript Observable.using方法代码示例

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


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

示例1: it

    it('delays change notifications until disabled', (done) => {
      const prop = new ReactiveValueProperty(testOwner, 0);
      const subject = new BehaviorSubject<number>(0);

      prop.changed
        .map(x => x.value)
        .subscribe(subject);

      subject.value.should.eql(0);

      prop.value = 1;
      subject.value.should.eql(1);

      subject
        .subscribe(x => {
          if (x === 3) {
            done();
          }
        });

      Observable.using(
        () => prop.delayChangeNotifications(),
        x => {
          prop.value = 2;
          subject.value.should.eql(1);

          prop.value = 3;
          subject.value.should.eql(1);

          x.unsubscribe();
        }
      ).subscribe();
    });
开发者ID:patsissons,项目名称:rxobj,代码行数:33,代码来源:ReactiveProperty.spec.ts

示例2:

        sub1 => {
          prop.value = 2;
          subject.value.should.eql(1);

          Observable.using(
            () => prop.delayChangeNotifications(),
            sub2 => {
              prop.value = 3;
              subject.value.should.eql(1);

              sub2.unsubscribe();
            }
          ).subscribe();

          subject.value.should.eql(1);

          sub1.unsubscribe();
        }
开发者ID:patsissons,项目名称:rxobj,代码行数:18,代码来源:ReactiveProperty.spec.ts

示例3: it

    it('suppresses execution when suppressed', () => {
      const cmd = new ReactiveCommand(testOwner, x => true);
      const results = new BehaviorSubject(false);

      cmd.results.subscribe(results);

      Observable.using(
        () => cmd.suppressChangeNotifications(),
        x => {
          cmd.execute();

          results.value.should.be.false;

          x.unsubscribe();

          results.value.should.be.false;
        }
      ).subscribe();
    });
开发者ID:patsissons,项目名称:rxobj,代码行数:19,代码来源:ReactiveCommand.spec.ts

示例4: it

    it('re-subscribes the default observer', () => {
      const subject1 = new BehaviorSubject(0);
      const subject2 = new BehaviorSubject(0);
      const ss = new SubjectScheduler(ReactiveApp.mainScheduler, subject1);

      ss.next(1);
      subject1.value.should.eql(1);

      Observable.using(
        () => ss.subscribe(subject2),
        x => {
          ss.next(2);
          subject1.value.should.eql(1);
          subject2.value.should.eql(2);

          x.unsubscribe();
        }
      ).subscribe();

      ss.next(3);
      subject1.value.should.eql(3);
      subject2.value.should.eql(2);
    });
开发者ID:patsissons,项目名称:rxobj,代码行数:23,代码来源:SubjectScheduler.spec.ts


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