Refactoring
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user