Skip to main content
Module

x/effection/mod.ts>Context

Structured concurrency and effects for JavaScript
Latest
interface Context
implements Operation<T>
Re-export
import { type Context } from "https://deno.land/x/effection@3.0.3/mod.ts";

`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.

Properties

readonly
key: string

A unique identifier for this context.

readonly
optional
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.