Effection 3.0 – Structured Concurrency and Effects for JavaScript
frontside.com`redux-saga` maintainer here.
I've been using `effection` to build a replacement for `redux-saga` over at https://github.com/neurosnap/starfx
Effection has demonstrated to me how truly powerful delimited continuations are and why structured concurrency is an incredible asset for anything that requires async flow control -- basically everything in TS/JS.
I know sometimes it's hard to imagine why someone would need structured concurrency or care about delimited continuations for a front-end application, but this is a game changer in terms of expressing async flow control.
Some things to note about Effection:
- API surface area is small https://github.com/thefrontside/effection/issues/851
- It tries to stay as close to JS constructs as possible so it will feel very familiar
- Resource cleanup is automatic (when a function passes out of scope all descendent tasks are shut down automatically)
- End-user doesn't need to think about delimited continuations
The only leap users need to learn coming from async/await is the syntax.
import { main, call } from "effection";
await main(function*() {
const response = yield* call(fetch("my-api.com"));
const data = yield* call(response.json);
});
In this way, effection is very approachable and I highly recommend people try it out.Here is an example of using Effection with React to build a sophisticated loader https://github.com/taras/effection-react-loadingspinner