import { Context, Effect, Layer, pipe } from "effect"
class Dep1 extends Context.Tag("Dep1")<Dep1, string>() {};
class Dep2 extends Context.Tag("Dep2")<Dep1, string>() {};
const live =
Layer.mergeAll(
Layer.succeed(
Dep1,
"production dep 1"
),
Layer.succeed(
Dep2,
"production dep 2"
),
)
const liveWithReplacedDep =
live.pipe(
Layer.provide(
Layer.succeed(
Dep1,
"test"
)
)
)
pipe(
Effect.Do,
Effect.bind("dep1", () => Dep1),
Effect.bind("dep2", () => Dep2),
Effect.andThen(Effect.logInfo),
Effect.provide(liveWithReplacedDep),
Effect.runSync
)
import { Context, Effect, Layer, pipe } from "effect"
class Dep1 extends Context.Tag("Dep1")<Dep1, string>() {};
class Dep2 extends Context.Tag("Dep2")<Dep1, string>() {};
const live =
Layer.mergeAll(
Layer.succeed(
Dep1,
"production dep 1"
),
Layer.succeed(
Dep2,
"production dep 2"
),
)
const liveWithReplacedDep =
live.pipe(
Layer.provide(
Layer.succeed(
Dep1,
"test"
)
)
)
pipe(
Effect.Do,
Effect.bind("dep1", () => Dep1),
Effect.bind("dep2", () => Dep2),
Effect.andThen(Effect.logInfo),
Effect.provide(liveWithReplacedDep),
Effect.runSync
)