zl程序教程

您现在的位置是:首页 >  其它

当前栏目

[RxJS] Using iif

Using Rxjs
2023-09-14 08:59:12 时间

If you have a popup window, if value is false should close the popup, true is displaying the popup.

But if value is ture, you want to delay 365ms before it open the popup;

If value is false, you want to close the popup right away.

    this.isOpen$ = merge(
      this.closeDialogSubject.asObservable().pipe(mapTo(false)),
      this.display$.pipe(mergeMap((open: boolean) => iif(() => open, timer(DEBOUNCE_TIME).pipe(mapTo(true)), of(false))))
    );