本文整理汇总了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();
});
示例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();
}
示例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();
});
示例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);
});