Creating a managed runtime for dependency injection in Effect can be achieved by setting up a cen...

im having trouble figuring out how to make a managed runtime with Effect.Service

if I setup my services so that I have something like

RepositoryName.Default or .Test
and
ServiceName.Default (with a dependncy on RepositoryName.Default) and .Test


I know that I can run the "program" like this

// Run default implementation
const mainProgram = Effect.gen(function* () {
    const myService = yield* Service
    const serviceResult = yield* myService.doSomethingMore()
    console.log("Service Result:", serviceResult)

    return Effect.succeed("Done")
})

const result = Effect.runSync(
    mainProgram.pipe(
        Effect.provide(Service.Default),

    )
)

(thank you Lucas Barake)


but how can I make a managed runtime for this so that everytime I need to run my service, I can DI the entire stack from one place?
Was this page helpful?