Interface: Context<T>
A context.
Type Parameters
| Type Parameter |
|---|
T |
Methods
apply()
apply<R>(fn, value): R;
Applies a value override while the given function is running and, if a node is returned, sets the node as a provider of the value.
Type Parameters
| Type Parameter | Description |
|---|---|
R |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | () => R | Function to run. |
value | T | Value to apply. |
Returns
R
The value returned from the function.
applyComputed()
applyComputed<R>(fn, valueFn): R;
Applies a computed value override while the given function is running and, if a node is returned, sets the node as a provider of the computed value.
Type Parameters
| Type Parameter | Description |
|---|---|
R |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | () => R | Function to run. |
valueFn | () => T | Function that returns the value to apply. |
Returns
R
The value returned from the function.
get()
get(node): T;
Gets the context value for a given node.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | object | - |
Returns
T
getDefault()
getDefault(): T;
Gets the context default value.
Returns
T
getProviderNode()
getProviderNode(node): object | undefined;
Gets node that will provide the context value, or undefined
if it comes from the default.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | object | - |
Returns
object | undefined
set()
set(node, value): void;
Sets the context value for a given node, effectively making it a provider.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | object | - |
value | T | - |
Returns
void
setComputed()
setComputed(node, valueFn): void;
Sets the context value resolver for a given node, effectively making it a provider.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | object | - |
valueFn | () => T | - |
Returns
void
setDefault()
setDefault(value): void;
Sets the context default value.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | T | - |
Returns
void
setDefaultComputed()
setDefaultComputed(valueFn): void;
Sets the context default value resolver.
Parameters
| Parameter | Type | Description |
|---|---|---|
valueFn | () => T | - |
Returns
void
unset()
unset(node): void;
Unsets the context value for a given node, therefore it won't be a provider anymore.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | object | - |
Returns
void