Closed borosbela closed 2 months ago
Hi @borosbela,
If you subscribe to your iif
Observable, you'll see that it only logs other way
. one way
is not logged and will not be logged as long as the function passed as the first parameter to iif
returns falsy value. Please visit this link for demo.
The reason why Why?
gets logged is because you're actually calling firstObs
function when preparing the second parameter for iif
which calls console.log("Why?")
before returning of("one way")
. This has nothing to do with RxJS, it's just how JavaScript works.
If you need to postpone execution of firstObs
, you can use this:
import { defer, iif } from 'rxjs';
iif(() => false,
defer(firstObs),
defer(secondObs)
)
I'm gonna close this issue as there's no bug here.
Describe the bug
The documentation says, that only
trueResult
of the given observables will be subscribed, but both of thefalseResult
andtrueResult
will be subsrcibed to, and only returns thetrueResult
observable's value.Expected behavior
Only subsrcibe to the
trueResult
observable.Reproduction code
Reproduction URL
No response
Version
7.8.1
Environment
No response
Additional context
No response