You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perhaps use https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/ban-observables.md to disallow iif. It may be confusing that both branches do get evaluated (as they are just params to a function) to some. While thats due to language itself, people seem to often miss it which causes unexpected behavior. defer can be used to work around that but that is even less known if I had to guess.
When you will want to catch errors within the switchMap, the difference becomes even more glaring. You can work around it, but iif would be more succint. Sadly, if we were to forbid iif, some code would expand quite quickly.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Perhaps use https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/ban-observables.md to disallow
iif
. It may be confusing that both branches do get evaluated (as they are just params to a function) to some. While thats due to language itself, people seem to often miss it which causes unexpected behavior.defer
can be used to work around that but that is even less known if I had to guess.Some uses can be refactored easily:
From:
To:
Most useful usecase of
iff
is being able to pipe whatever would be subscribed to near the condition.As opposed to:
When you will want to catch errors within the switchMap, the difference becomes even more glaring. You can work around it, but
iif
would be more succint. Sadly, if we were to forbidiif
, some code would expand quite quickly.Beta Was this translation helpful? Give feedback.
All reactions