Best Practices for Creating Parameterized ManagedRuntime in Effect

Hello Effect folks,

I need to create a parameterized runtime, that is I need to supply ManagedRuntime with initial data.

I am comfortable using ManagedRuntime in the traditional sense as a module singleton, e.g.
// runtime.ts
import * as ManagedRuntime from 'effect/ManagedRuntime'r

export const runtime = ManagedRuntime.make(...)

// consumer.ts
import { runtime } from './runtime.js'

runtime.runPromiseExit(...)


But if I were instead to need
// runtime.ts
import * as ManagedRuntime from 'effect/ManagedRuntime'

export const runtime = (x: ...) => ManagedRuntime.make(...)

is there a known best practice for this scenario? Ultimately the input will be satisfying layer creation for a simple static context and determining log-level upon initialization.

Edit: This is a React boundary use case, but the runtime could be consumed by multiple layers. I could use a mutable let, but there must be a better approach.
Was this page helpful?