ScopeMap -> ScopeRegistry
Lint / lint (push) Failing after 43s

This commit is contained in:
Julien Valverdé
2026-07-22 22:51:38 +02:00
parent c151b4608f
commit 8fed17789a
5 changed files with 43 additions and 38 deletions
@@ -0,0 +1,26 @@
import { Context, Effect, type Fiber, HashMap, Layer, type Option, Ref, type Scope } from "effect"
/**
* Internal Effect service that maintains a registry of scopes associated with React component instances.
*
* This service is used internally by the `Component.useScope` hook to manage the lifecycle of component scopes,
* including tracking active scopes and coordinating their cleanup when components unmount or dependencies change.
*/
export class ScopeRegistry extends Context.Service<ScopeRegistry, {
readonly ref: Ref.Ref<HashMap.HashMap<object, ScopeRegistry.Entry>>
}>()(
"@effect-fc/ScopeRegistry/ScopeRegistry"
) {
static readonly layer = Layer.effect(ScopeRegistry, Effect.map(
Ref.make(HashMap.empty<object, ScopeRegistry.Entry>()),
ref => ({ ref }),
))
}
export declare namespace ScopeRegistry {
export interface Entry {
readonly scope: Scope.Closeable
readonly closeFiber: Option.Option<Fiber.Fiber<void>>
}
}