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