Integrating Effect with Callback-Driven Code

Hello wonderful people,

I have a question regarding integrating effect with callback-driven code

TLDR:

declare const externalFunction = (nextRandom: () => number): void;

// nextRandom() is called n times, n isn't known

Effect.gen(function* () {
  externalFunction(() => yield* Random.next/*that of course won't do*/)
});

// ^ TLDR

Now, generally is there a nice way to call an effect from [a synchronous] function callback? In https://www.youtube.com/watch?v=7jOD5okJC00 I found a technique with FiberSet.makeRuntime where I'll run Random.next in the callback, but I seriously doubt it won't return the same "random" number every call (or wouldn't it?) since the service is stateful PRNG
Screenshot_2024-05-19_at_5.03.44_PM.png
Was this page helpful?