Skip to main content

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 ParameterDescription
R

Parameters​

ParameterTypeDescription
fn() => RFunction to run.
valueTValue 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 ParameterDescription
R

Parameters​

ParameterTypeDescription
fn() => RFunction to run.
valueFn() => TFunction 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​

ParameterTypeDescription
nodeobject-

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​

ParameterTypeDescription
nodeobject-

Returns​

object | undefined


set()​

set(node, value): void;

Sets the context value for a given node, effectively making it a provider.

Parameters​

ParameterTypeDescription
nodeobject-
valueT-

Returns​

void


setComputed()​

setComputed(node, valueFn): void;

Sets the context value resolver for a given node, effectively making it a provider.

Parameters​

ParameterTypeDescription
nodeobject-
valueFn() => T-

Returns​

void


setDefault()​

setDefault(value): void;

Sets the context default value.

Parameters​

ParameterTypeDescription
valueT-

Returns​

void


setDefaultComputed()​

setDefaultComputed(valueFn): void;

Sets the context default value resolver.

Parameters​

ParameterTypeDescription
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​

ParameterTypeDescription
nodeobject-

Returns​

void