Appearance
@shtse8/fluxus / src / ScopeReader
Interface: ScopeReader
Defined in: src/types.ts:24
Provides read access to other providers within the current scope and methods for managing the lifecycle of the current provider's state. Passed to the provider's creation function.
Properties
signal?
readonlyoptionalsignal:AbortSignal
Defined in: src/types.ts:58
An AbortSignal that is aborted when the provider's state is disposed. This can be used to cancel asynchronous operations like fetch requests when the provider is no longer needed. Only relevant for async providers.
Methods
onDispose()
onDispose(
callback):void
Defined in: src/types.ts:50
Adds a cleanup function to be called when the provider's state associated with the current scope is disposed.
Parameters
callback
The cleanup function to be executed.
Returns
void
read()
read<
T>(provider):T
Defined in: src/types.ts:34
Reads the current value of a provider without subscribing to updates. If the provider is not yet initialized in the scope, it will be created.
Type Parameters
T
T
Parameters
provider
Provider<T>
The provider to read.
Returns
T
The current value of the dependency provider within the current scope.
watch()
watch<
T>(provider):T
Defined in: src/types.ts:43
Watches the value of a provider and subscribes to updates. This is typically used by reactive providers or UI bindings.
Type Parameters
T
T
Parameters
provider
Provider<T>
The dependency provider to watch.
Returns
T
The current value of the provider.