本文整理匯總了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);
});