本文整理汇总了TypeScript中rxjs/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)
.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],
Rx.Scheduler.queue
);
const subscriber = Rx.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');