Observables, Side-Effects, and Subscriptions: Some Reactive Best Practices
If there’s any common thread in my advice, it is: delay unpacking an Observable into its scalar types when performing logic you can rewrite as side-effect-free, leaving code with side-effects for subscription callbacks and other downstream logic. One final reason side-effects are bad in operators: that these side-effects can be performed an arbitrary number of times per event based on how many distinct subscribers are listening to an Observable. An Observable going through a series of transformation operators from source to final result is:
I propose side-effects being a great first-order heuristic as far as what can reasonably be kept within a composed Observable.
Source: blog.eyas.sh