router.createUrlTree
defer(() => {
let buffer = [];
return source$.pipe(
withLatestFrom(trigger$),
tap(([src]) => buffer.push(src)),
mergeMap(([src, trigger]) => trigger ? buffer : NEVER),
tap(() => buffer = []),
)
});
startWith(false)
для начального значенияbuffer
, но чет не придумалось. ngOnInit() {
fromEvent(document, 'click')
.pipe(debounceTime(300))
.subscribe((event) => {
const targetElement = event.target;
if(!targetElement) {
return;
}
const clickedInside = this.elementRef.nativeElement.contains(targetElement);
if(!clickedInside) {
this.clickOutside.emit(event);
}
});
}