本文整理汇总了TypeScript中rxjs/operators.takeUntil函数的典型用法代码示例。如果您正苦于以下问题:TypeScript takeUntil函数的具体用法?TypeScript takeUntil怎么用?TypeScript takeUntil使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了takeUntil函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should dispose notifier if source observable completes', () => {
const e1 = hot('--a--| ');
const e1subs = '^ ! ';
const e2 = hot('-------x--|');
const e2subs = '^ ! ';
const expected = '--a--| ';
expectObservable(e1.pipe(takeUntil(e2))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});
示例2: ngOnInit
// -----------------------------------------------------------------------------------------------------
// @ Lifecycle hooks
// -----------------------------------------------------------------------------------------------------
/**
* On init
*/
ngOnInit(): void
{
// Subscribe to config changes
this._fuseConfigService.config
.pipe(takeUntil(this._unsubscribeAll))
.subscribe(
(config) => {
this.fuseConfig = config;
}
);
}
示例3: asDiagram
asDiagram('takeUntil')('should take values until notifier emits', () => {
const e1 = hot('--a--b--c--d--e--f--g--|');
const e1subs = '^ ! ';
const e2 = hot('-------------z--| ');
const e2subs = '^ ! ';
const expected = '--a--b--c--d-| ';
expectObservable(e1.pipe(takeUntil(e2))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});
示例4: switchMap
switchMap(() => merge( // then emit every 500ms, and when the navigation ends or cancels or errors. This delay must
// match the transition duration in the .scss file
timer(0, 500).pipe(
map(i => 100 - (100 / Math.pow(2, i))), // emit 0 then 50, 75, 87.5, etc.
takeWhile(i => i < 99.95), // stop because that just triggers change detection with no visual change anymore
takeUntil(end$), // but stop emitting every 500ms when the navigation ends or cancels or errors
map(i => ({ value: i }))
),
end$.pipe(first(), map(() => null)) // set back to null when the navigation ends or cancels or errors to hide
// the progress bar
))