Effect CommunityEC
Effect Community•2y ago•
23 replies
addamsson

The Use of `runFork` in Express Example Code

I'm looking at the example code for express and I was wondering about why runFork is used here:
const IndexRouteLive = Layer.effectDiscard(
    Effect.gen(function* (_) {
        const app = yield* _(Express);
        const runFork = Runtime.runFork(yield* _(Effect.runtime<never>()));

        app.get("/", (_, res) => {
            runFork(Effect.sync(() => res.send("Hello World!")));
        });
    })
);

What is the benefit of using runFork compared to other options I can see in the documentation (such as runSync or runPromise)?
I'm just not 💯 sure what runFork does and why it was chosen here.
Was this page helpful?