I'm not going to discuss the motivation behind throwing effects vs executing them right away inside a function. The question just translates to why we should separate pure and impure computations, which is a whole subject ont its own.
I think in Javascript it should be the goal to be explicit about which portion of the code is impure and to separate it from the "pure portion" on the temporal rather then the spacial axis (separate the code).
We can achieve this temporal separation by deferring the evaluation of impure code through thunks. However, we don't want thunks flying around throughout our code, so we wrap them in an object type and define some operators to be able to lift normal functions into this type and to chain operations on this type.
Now we can compose eventually-impure with pure code and unleash the effects later explicitly by calling e.g.
We can achieve this temporal separation by deferring the evaluation of impure code through thunks. However, we don't want thunks flying around throughout our code, so we wrap them in an object type and define some operators to be able to lift normal functions into this type and to chain operations on this type.
Sounds like the main idea behind redux-saga library.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think in Javascript it should be the goal to be explicit about which portion of the code is impure and to separate it from the "pure portion" on the temporal rather then the spacial axis (separate the code).
We can achieve this temporal separation by deferring the evaluation of impure code through thunks. However, we don't want thunks flying around throughout our code, so we wrap them in an object type and define some operators to be able to lift normal functions into this type and to chain operations on this type.
Now we can compose eventually-impure with pure code and unleash the effects later explicitly by calling e.g.
Sounds like the main idea behind
redux-saga
library.