(
service: Context.Key<I, A>,
update: (value: A) => A,
options?: {
readonly reset?: ((original: A, updated: A, current: A) => A) | undefined
} | undefined
)
| 2123 | |
| 2124 | /** @internal */ |
| 2125 | export const updateServiceScoped = <I, A>( |
| 2126 | service: Context.Key<I, A>, |
| 2127 | update: (value: A) => A, |
| 2128 | options?: { |
| 2129 | readonly reset?: ((original: A, updated: A, current: A) => A) | undefined |
| 2130 | } | undefined |
| 2131 | ): Effect.Effect<void, never, I | Scope.Scope> => |
| 2132 | uninterruptible(withFiber((fiber) => { |
| 2133 | const original = Context.getUnsafe(fiber.context, service) |
| 2134 | const updated = update(original) |
| 2135 | fiber.setContext(Context.add(fiber.context, service, updated)) |
| 2136 | return scopeAddFinalizerExit(Context.getUnsafe(fiber.context, scopeTag), (_) => { |
| 2137 | const current = Context.getUnsafe(fiber.context, service) |
| 2138 | let next: A |
| 2139 | if (options?.reset === undefined) { |
| 2140 | if (current !== updated) return void_ |
| 2141 | next = original |
| 2142 | } else { |
| 2143 | next = options.reset(original, updated, current) |
| 2144 | } |
| 2145 | fiber.setContext(Context.add(fiber.context, service, next)) |
| 2146 | return void_ |
| 2147 | }) |
| 2148 | })) |
| 2149 | |
| 2150 | /** @internal */ |
| 2151 | export const context = <R = never>(): Effect.Effect<Context.Context<R>> => getContext as any |
nothing calls this directly
no test coverage detected