本文整理汇总了TypeScript中rxjs/operators.takeLast函数的典型用法代码示例。如果您正苦于以下问题:TypeScript takeLast函数的具体用法?TypeScript takeLast怎么用?TypeScript takeLast使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了takeLast函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: observableDefer
return observableDefer(() => {
log.debug("Init: Trying to call endOfStream");
if (mediaSource.readyState !== "open") {
log.debug("Init: MediaSource not open, cancel endOfStream");
return observableOf(null);
}
const { sourceBuffers } = mediaSource;
const updatingSourceBuffers = getUpdatingSourceBuffers(sourceBuffers);
if (!updatingSourceBuffers.length) {
log.info("Init: Triggering end of stream");
mediaSource.endOfStream();
return observableOf(null);
}
log.debug("Init: Waiting SourceBuffers to be updated before calling endOfStream.");
const updatedSourceBuffers$ = updatingSourceBuffers
.map((sourceBuffer) => onUpdate$(sourceBuffer).pipe(take(1)));
return observableRace(
observableMerge(...updatedSourceBuffers$).pipe(takeLast(1)),
onRemoveSourceBuffers$(sourceBuffers).pipe(take(1))
).pipe(mergeMap(() => {
return triggerEndOfStream(mediaSource);
}));
});
示例2: it
it('should take one value from an observable with many values', () => {
const e1 = hot('--a--^--b----c---d--| ');
const e1subs = '^ ! ';
const expected = '---------------(d|)';
expectObservable(e1.pipe(takeLast(1))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});
示例3: it
it('completes when service is stopped', async () => {
const last$ = start
.getNavLinks$()
.pipe(takeLast(1))
.toPromise();
service.stop();
await expect(last$).resolves.toBeInstanceOf(Array);
});