[RxJS] Using iif


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))))
    );