本文整理汇总了TypeScript中rxjs.NEVER类的典型用法代码示例。如果您正苦于以下问题:TypeScript NEVER类的具体用法?TypeScript NEVER怎么用?TypeScript NEVER使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NEVER类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should unsubscribe former observables if a latter one emits immediately', () => {
const onNext = sinon.spy();
const onUnsubscribe = sinon.spy();
const e1 = NEVER.finally(onUnsubscribe); // Should be unsubscribed
const e2 = Observable.of('b'); // Wins the race
e1.race(e2).subscribe(onNext);
expect(onNext.calledWithExactly('b')).to.be.true;
expect(onUnsubscribe.calledOnce).to.be.true;
});
示例2: it
it('should count references', () => {
const connectable = NEVER.pipe(publish());
const refCounted = connectable.pipe(
refCount()
);
const sub1 = refCounted.subscribe({
next: noop
});
const sub2 = refCounted.subscribe({
next: noop,
});
const sub3 = refCounted.subscribe({
next: noop,
});
expect((connectable as any)._refCount).to.equal(3);
sub1.unsubscribe();
sub2.unsubscribe();
sub3.unsubscribe();
});
示例3:
observable1 = constructorZone1.run(() => {
return NEVER.pipe(startWith(7));
});
示例4: it
it("source observable prefixed with startWith overrides initialValue", async t => {
const obs = NEVER.pipe(startWith(13));
const value = obs.toState(0);
t.is(value.getValue(), 13);
});