Running Programs in a Forever Loop with Effect and Fork
is this a good approach to keep two or more programs running in a forever cycle?
import { Effect } from "effect";
const FirstThread = Effect.forever(
Effect.gen(function* () {
yield* Effect.log("First thread").pipe(Effect.delay("10 millis"));
})
);
const SecondThread = Effect.forever(
Effect.gen(function* () {
yield* Effect.log("Second thread").pipe(Effect.delay("10 millis"));
})
);
const program = Effect.all([
Effect.fork(FirstThread),
Effect.fork(SecondThread),
Effect.never
]);
Effect.runFork(program);