本文整理匯總了TypeScript中rxjs/internal/observable/fromIterable.fromIterable函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fromIterable函數的具體用法?TypeScript fromIterable怎麽用?TypeScript fromIterable使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了fromIterable函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should finalize generators if the subscription and it is scheduled', () => {
const iterator = {
finalized: false,
next() {
return { value: 'duck', done: false };
},
return() {
this.finalized = true;
}
};
const iterable = {
[Rx.Symbol.iterator]() {
return iterator;
}
};
const results: any[] = [];
fromIterable(iterable as any, queue)
.pipe(take(3))
.subscribe(
x => results.push(x),
null,
() => results.push('GOOSE!')
);
expect(results).to.deep.equal(['duck', 'duck', 'duck', 'GOOSE!']);
expect(iterator.finalized).to.be.true;
});
示例2: fromIterable
'but is unsubscribed early', (done) => {
const expected = [10, 20, 30, 40];
const source = fromIterable(
[10, 20, 30, 40],
queueScheduler
);
const subscriber = Subscriber.create(
(x) => {
expect(x).to.equal(expected.shift());
if (x === 30) {
subscriber.unsubscribe();
done();
}
}, (x) => {
done(new Error('should not be called'));
}, () => {
done(new Error('should not be called'));
});
source.subscribe(subscriber);
});
示例3: expect
expect(() => {
fromIterable(void 0, undefined);
}).to.throw(Error, 'Iterable cannot be null');