interface Context
thefrontside/effectioninterface Context<T> extends Operation<T>
`Context`` defines a value which is in effect for a given scope which is an (action, resource, call, or spawn).
When used as an operation, it gets the value of the Context from
the current scope. If it has not been set, and there is no default
value, then a MissingContextError
will be raised.
Unless a context value is defined for a particular scope, it will inherit its value from its parent scope.
Type Parameters
T
Properties
- key: string
A unique identifier for this context.
- defaultValue: T
The value of the context if has not been defined for the current operation.
Methods
- set(value: T): Operation<T>
Set the value of the Context for the current scope.
- get(): Operation<T | undefined>
Get the value of the Context from the current scope. If it has not been set, and there is no default value, then this will return
undefined
.- expect(): Operation<T>
Get the value of the Context from the current scope. An error will be raised if the context has not been defined.