import { Atom } from "@effect-atom/atom-react"import { Effect } from "effect"class Users extends Effect.Service<Users>()("app/Users", { effect: Effect.gen(function* () { const getAll = Effect.succeed([ { id: "1", name: "Alice" }, { id: "2", name: "Bob" }, { id: "3", name: "Charlie" }, ]) return { getAll } as const }),}) {}// Create a `AtomRuntime` from a `Layer`.//// ┌─── Atom.AtomRuntime<Users>// ▼const runtimeAtom = Atom.runtime(Users.Default)// You can then use the `AtomRuntime` to make Atoms that use the services from the `Layer`.const usersAtom = runtimeAtom.atom( Effect.gen(function* () { const users = yield* Users return yield* users.getAll }),)
import { Atom } from "@effect-atom/atom-react"import { Effect } from "effect"class Users extends Effect.Service<Users>()("app/Users", { effect: Effect.gen(function* () { const getAll = Effect.succeed([ { id: "1", name: "Alice" }, { id: "2", name: "Bob" }, { id: "3", name: "Charlie" }, ]) return { getAll } as const }),}) {}// Create a `AtomRuntime` from a `Layer`.//// ┌─── Atom.AtomRuntime<Users>// ▼const runtimeAtom = Atom.runtime(Users.Default)// You can then use the `AtomRuntime` to make Atoms that use the services from the `Layer`.const usersAtom = runtimeAtom.atom( Effect.gen(function* () { const users = yield* Users return yield* users.getAll }),)
What you I need to do if I want to test a component that uses the
usersAtom
usersAtom
? How can I replace the runtime
Users.Default
Users.Default
layer with a mocked layer on the
runtimeAtom
runtimeAtom
in my test without changing the tested component code?