Refactoring

This commit is contained in:
Julien Valverdé
2024-07-04 21:26:16 +02:00
parent 7b578c657a
commit 5f15dedfbf
7 changed files with 36 additions and 33 deletions

View File

@@ -6,4 +6,7 @@ import type { TRPCContext } from "./context"
const createTRPC = () => initTRPC.context<TRPCContext>().create()
export class TRPCBuilder extends Context.Tag("TRPCBuilder")<TRPCBuilder, ReturnType<typeof createTRPC>>() {}
export const TRPCBuilderLive = Layer.sync(TRPCBuilder, createTRPC)
export module TRPCBuilder {
export const Live = Layer.sync(TRPCBuilder, createTRPC)
}

View File

@@ -1,19 +1,19 @@
import { Context, Effect, Layer, Runtime } from "effect"
import type { RuntimeFiber } from "effect/Fiber"
import { AppLive, type AppR } from "../App"
import type { Services } from "../Services"
export class TRPCEffectRuntime extends Context.Tag("TRPCEffectRuntime")<TRPCEffectRuntime,
<A, E>(
self: Effect.Effect<A, E, AppR>,
self: Effect.Effect<A, E, Services>,
options?: Runtime.RunForkOptions,
) => RuntimeFiber<A, E>
>() {}
export const TRPCEffectRuntimeLive = Layer.effect(TRPCEffectRuntime,
Effect.runtime<AppR>().pipe(
Effect.map(Runtime.runFork)
export module TRPCEffectRuntime {
export const Live = Layer.effect(TRPCEffectRuntime,
Effect.runtime<Services>().pipe(
Effect.map(Runtime.runFork)
)
)
).pipe(
Layer.provide(AppLive)
)
}