Pure Logics and Side Effects
So pure logic is something that i showed you with counter example where you can increase
, decrease
or reset
the counter. But you might see that this is trivial to lift such pure functions into RxJS. Side-effects are actually what RxJS shine at.
Actually, you don't have to reimplement such pure functions or lift them to RxJS space. For example, you have a component called <TodoList />
. What you can do to avoid reimplementing all the logics is to lift the state up:
And wrap it inside a subscription:
Then, you can have a common routine for pure logics:
And seperate routines for side-effects to take place:
Last updated
Was this helpful?