import { NodeRuntime } from '@effect/platform-node'
import { Context, Effect, Layer } from 'effect'
class MyService extends Context.Tag('MyService')<
MyService,
boolean
>() {}
const live = Layer.scoped(
MyService,
Effect.acquireRelease(
Effect.succeed(true).pipe(Effect.tap(x => Effect.log(`aquiring ${x}`))),
_ => Effect.unit.pipe(Effect.tap(x => Effect.log(`releasing ${x}`))),
),
)
const program = Effect.flatMap(
MyService,
value => Effect.log(`running: with ${value}`),
)
const runnable = Effect.provide(
program,
live,
)
NodeRuntime.runMain(runnable)
import { NodeRuntime } from '@effect/platform-node'
import { Context, Effect, Layer } from 'effect'
class MyService extends Context.Tag('MyService')<
MyService,
boolean
>() {}
const live = Layer.scoped(
MyService,
Effect.acquireRelease(
Effect.succeed(true).pipe(Effect.tap(x => Effect.log(`aquiring ${x}`))),
_ => Effect.unit.pipe(Effect.tap(x => Effect.log(`releasing ${x}`))),
),
)
const program = Effect.flatMap(
MyService,
value => Effect.log(`running: with ${value}`),
)
const runnable = Effect.provide(
program,
live,
)
NodeRuntime.runMain(runnable)