My objective here is to utilize startWith conditionally based on the value of another observable.
I attempted using mergeMap instead of map and encapsulated the return values with 'of' but it didn't yield the desired results.
fromEvent(element.nativeElement,'click').pipe(
withLatestFrom(this.isMobileView$),
map(([event, isMobileView]) => {
if (isMobileView) {
// perform certain actions
return false;
} else {
// perform other actions
// return a boolean variable
return this._drawer.opened;
}// TODO: consider nativescript code here
}),
// I aim to incorporate 'isMobileView' in my startWith
// something like startWith(!isMobileView)
startWith(true),
);
Expecting the sequence of observables to begin with false when in mobile view and true otherwise.