Effect CommunityEC
Effect Community2mo ago
11 replies
spaceemotion

Running Effect on the Browser: Understanding ManagedRuntime vs. BrowserRuntime

Okay, so this might sound a bit weird - but I am trying to run Effect on a client/browser and don't quite know how to "start" Effect.
So far, I've been using Vue in a global scope using a ManagedRuntime, like so:
export type AppRuntime = ReturnType<typeof createRuntime>;

export const createRuntime = () => {
  return ManagedRuntime.make(
    Layer.mergeAll(
      // ...
    ),
  );
};

export const useRuntime = createGlobalState(() => {
  const runtime = createRuntime();

  onScopeDispose(() => {
    runtime.dispose();
  });

  return runtime;
});


However, I recently found the BrowserRuntime - but have no clue how that fits in? Am I missing something here? From what I can tell that runtime only has an interrupt handler which seems to be missing if I'm not using it. How is effect running any kind of effects if there's no "program" running at all, or is it just using a global fiber on the managed runtime?
Was this page helpful?