Assume func
is a synchronized function. tap(_ => func())
will call the function lazily. However, mapTo(func())
will call the function eagerly.
forkJoin
will not emit anything if the input is an empty array.forkJoin
only emit one value than complete.- Use
zip
when you want to emit more than one values.
toArray
only works on source observable completed.- Use
scan((acc, arr) => [...acc, ...arr], [] as T)
to emit values without the source completing. However, this might cause duplicated elements in emitted values.
You never know if an observable emits more than one value! Thus, I prefer use Promise
as a "eager" replacement for Single
.
The finalize
operator will not get invoked in the order you expected. It will be invoked after unsubscription and thus makes the test of the function inside finalize impossible. See this issue for more details.
Marble test requires the observable to be synchronous. Thus, any observable from Promise, such as defer
or from
, will fail the test.