API reference
@searsuite/sear-foundation-subscription
Idempotent subscription ownership and reverse-order disposal utilities.
14 exportsderived from source
- classObservationErrorsource ↗
-
class ObservationError extends SearErrorPublic error raised when an observation definition or registry lifecycle contract is violated.
constructorconstructor ObservationError(code: ObservationErrorCode, message: string, details?: SearErrorDetails): ObservationErrorCreates an observation contract error with structured diagnostic details.
code: ObservationErrorCodemessage: stringdetails: SearErrorDetails
propertycode readonly code: ObservationErrorCodeStable observation-specific error code.
Inherited members 9
Inherited from SearError.
- classObservationRegistrysource ↗
-
class ObservationRegistryEditor-local typed observation registry exposed to plugins and third-party hosts.
constructorconstructor ObservationRegistry(platform?: Platform): ObservationRegistryCreates a registry that reports isolated host listener failures through the platform.
platform: Platform
propertysymbolstatic readonly symbol: typeof symbolDI token for resolving the registry owned by one editor instance.
methoddestroy destroy(): voidDisposes every active host subscription and removes all registered sources.
methodenforceWriteBoundary enforceWriteBoundary(assertWrite: (): void, runListener?: ObservationListenerScope, detachValue?: (value: unknown, definition: ObservationDefinition<unknown>): unknown): voidRequires editor command dispatch for source registration changes after assembly.
assertWrite: (): voidrunListener: ObservationListenerScopedetachValue: (value: unknown, definition: ObservationDefinition<unknown>): unknown
methodgetRegisteredObservations getRegisteredObservations(): readonly ObservationDefinition<unknown>[]Returns a stable snapshot of registered observation definitions sorted by id.
methodgetSnapshot getSnapshot<Value>(definition: StateObservationDefinition<Value>): ValueReturns the current snapshot for a state observation without subscribing.
definition: StateObservationDefinition<Value>
methodhas has(definition: string | ObservationDefinition<unknown>): booleanReturns whether an observation id is registered in this editor instance.
definition: string | ObservationDefinition<unknown>
methodregister register<Value>(definition: EventObservationDefinition<Value>, source: ObservationSource<Value>): (): voidregister<Value>(definition: StateObservationDefinition<Value>, source: StateObservationSource<Value>): (): voidRegisters an event-only source and returns an idempotent registration disposer.
definition: EventObservationDefinition<Value>source: ObservationSource<Value>
methodsubscribe subscribe<Value>(definition: ObservationDefinition<Value>, listener: (value: Value): void): (): voidSubscribes to a typed observation and returns an idempotent disposer.
definition: ObservationDefinition<Value>listener: (value: Value): void
- classSubscriptionManagersource ↗
-
class SubscriptionManagerOwns cancellable subscriptions for one consumer instance.
It centralizes disposal so viewport, DPR, visibility, network, and other observers do not each need a dedicated cleanup field.
constructorconstructor SubscriptionManager(platform: Platform): SubscriptionManagerCreates a SubscriptionManager instance.
platform: Platform
propertysymbolstatic readonly symbol: typeof symbolDI token for resolving SubscriptionManager.
methoddestroy destroy(): voidReleases resources owned by SubscriptionManager.
methodobserveResize observeResize(target: unknown, callback: (size: { height: number; width: number }): void): (): voidObserves host-view size changes and returns an idempotent disposer.
target: unknowncallback: (size: { height: number; width: number }): void
methodtrack track(dispose: (): void): (): voidTracks an arbitrary subscription cleanup function and returns an idempotent disposer.
dispose: (): void
- interfaceEventObservationDefinitionsource ↗
-
interface EventObservationDefinition<Value> extends ObservationDefinition<Value>Definition for an event-only observation stream.
propertykind readonly kind: "event"Event observations have no current snapshot.
- interfaceObservationDefinitionsource ↗
-
interface ObservationDefinition<Value>Typed identity imported by publishers and consumers of one observation.
propertyid readonly id: stringStable globally unique id used for registration diagnostics.
propertykind readonly kind: ObservationKindDelivery model that determines whether a current snapshot is available.
propertyvalueType readonly valueType?: ValueCompile-time value carrier; never populated at runtime.
- interfaceObservationSourcesource ↗
-
interface ObservationSource<Value>Produces future values for an event or state observation.
methodsubscribe subscribe(listener: (value: Value): void): (): voidRegisters a listener for future values and returns an idempotent disposer.
listener: (value: Value): void
- interfaceStateObservationDefinitionsource ↗
-
interface StateObservationDefinition<Value> extends ObservationDefinition<Value>Definition for an observation stream backed by a current state snapshot.
propertykind readonly kind: "state"State observations expose a current snapshot.
- interfaceStateObservationSourcesource ↗
-
interface StateObservationSource<Value> extends ObservationSource<Value>Produces a current snapshot plus future values for a state observation.
methodgetSnapshot getSnapshot(): ValueReturns the current immutable state snapshot.
- typeObservationErrorCodesource ↗
-
type ObservationErrorCode = typeof ObservationErrorCode[keyof typeof ObservationErrorCode]Machine-readable observation error code.
- typeObservationKindsource ↗
-
type ObservationKind = typeof ObservationKind[keyof typeof ObservationKind]Supported observation delivery models.
- variableObservationErrorCodesource ↗
-
ObservationErrorCode: { AlreadyRegistered: "SEAR_OBSERVATION_ALREADY_REGISTERED"; DefinitionMismatch: "SEAR_OBSERVATION_DEFINITION_MISMATCH"; InvalidDefinition: "SEAR_OBSERVATION_INVALID_DEFINITION"; NotRegistered: "SEAR_OBSERVATION_NOT_REGISTERED"; RegistryDestroyed: "SEAR_OBSERVATION_REGISTRY_DESTROYED"; SnapshotUnavailable: "SEAR_OBSERVATION_SNAPSHOT_UNAVAILABLE" }Stable machine-readable error codes for the observation extension surface.
- variableObservationKindsource ↗
-
ObservationKind: { Event: "event"; State: "state" }Distinguishes snapshot-backed state observations from event-only streams.
- functiondefineEventObservationsource ↗
-
defineEventObservation<Value>(id: string): EventObservationDefinition<Value>Creates a typed identity for an event-only observation stream.
id: string
- functiondefineStateObservationsource ↗
-
defineStateObservation<Value>(id: string): StateObservationDefinition<Value>Creates a typed identity for a snapshot-backed state observation stream.
id: string
No public exports match that search.