interface Context
thefrontside/effectioninterface Context<T>
Context
defines a value which is in effect for a given scope which is an
(action, resource, call, or spawn).
Unless a context value is defined for a particular scope, it will inherit its value from its parent scope.
Type Parameters
T
Properties
- name: string
A unique identifier for this context.
- defaultValue: T
The value returned by this context when it is not present on a scop.e
Methods
- get(): https://effection-www-s5a0jkwj0z5x.deno.dev/api/v4/Operation<T | undefined>
Read the current value of this context if it exists.
- set(value: T): https://effection-www-s5a0jkwj0z5x.deno.dev/api/v4/Operation<T>
Set the value of a context on the current scope. It will not effect the value of its containing scope and will only be visible by this scope and its children.
- expect(): https://effection-www-s5a0jkwj0z5x.deno.dev/api/v4/Operation<T>
Read the current value of the context or fail if it does not exist
- delete(): https://effection-www-s5a0jkwj0z5x.deno.dev/api/v4/Operation<boolean>
Remove a context value from the current scope. This will only effect the current scope and not its parent value.
- with<R>(value: T, operation: (value: T) => https://effection-www-s5a0jkwj0z5x.deno.dev/api/v4/Operation<R>): https://effection-www-s5a0jkwj0z5x.deno.dev/api/v4/Operation<R>
Evaluate an operation using
value
for the context. Once the operation is completed, the context will be reverted to its original value, or removed if it was not present originally.