refactor(effect): yield services instead of promise facades (#19325)

This commit is contained in:
Kit Langton
2026-03-26 21:46:38 -04:00
committed by GitHub
parent ef7d1f7efa
commit 9c6f1edfd7
19 changed files with 283 additions and 250 deletions

View File

@@ -35,12 +35,14 @@ export namespace Format {
export const layer = Layer.effect(
Service,
Effect.gen(function* () {
const config = yield* Config.Service
const state = yield* InstanceState.make(
Effect.fn("Format.state")(function* (_ctx) {
const enabled: Record<string, boolean> = {}
const formatters: Record<string, Formatter.Info> = {}
const cfg = yield* Effect.promise(() => Config.get())
const cfg = yield* config.get()
if (cfg.formatter !== false) {
for (const item of Object.values(Formatter)) {
@@ -167,7 +169,9 @@ export namespace Format {
}),
)
const { runPromise } = makeRuntime(Service, layer)
export const defaultLayer = layer.pipe(Layer.provide(Config.defaultLayer))
const { runPromise } = makeRuntime(Service, defaultLayer)
export async function init() {
return runPromise((s) => s.init())