Follow one execution
Use the caller-owned context without acquiring or releasing its service instances.
provideContextTick 0. Source: start; Existing service: ready.
Read this diagram
Follow each lane from left to right. Events stacked vertically share a tick; the green cursor marks the current time across every lane.
- A value
The text inside the pill is the emitted value. - Work starts
The raised chevron starts an inner run (^in the source). - The run returns
The vertical bar ends this lane’s run. - A cause is delivered
The exclamation mark belongs to this lane. - Work is interrupted
The cross marks cancellation of this run. - Current time
The line and diamond move together across all lanes. - Happening now
A highlighted event is at the current tick. - Still ahead
Muted, dashed values have not happened yet. - Time continues
The lane’s arrow is not a return marker. An empty stretch can be quiet work that is still running.
Illustrated ticks start at 0. At 1×, one illustrated tick takes one second; captions specify real durations when timing matters. A cause or interruption belongs to its lane, and other work may continue. Scroll horizontally to inspect the rest of a long timeline.
The Context is captured when this combinator is created and reused for each subscription. Its services are available to all source Effects and removed from R. This function does not acquire or release those service values; their owner must keep them valid for every subscription that uses the result. Source completion, failure, and interruption are unchanged.
Import
import { provideContext } from "@typed/fx/Fx";Signatures
export declare const provideContext: {
<R2>(services: Context.Context<R2>): <A, E, R>(fx: Fx<A, E, R>) => Fx<A, E, Exclude<R, R2>>;
<A, E, R, R2>(fx: Fx<A, E, R>, services: Context.Context<R2>): Fx<A, E, Exclude<R, R2>>;
};Why
Callers that already own service instances should not rebuild them through a resourceful Layer merely to satisfy an Fx’s environment.
Ownership and lifetime
The Context is captured when this combinator is created and reused for each
subscription. Its services are available to all source Effects and removed
from R. This function does not acquire or release those service values;
their owner must keep them valid for every subscription that uses the result.
Source completion, failure, and interruption are unchanged.
Examples
import { Context, Effect } from "effect"
import { provideContext } from "@typed/fx/Fx"
import { fromEffect } from "@typed/fx/Fx"
class Config extends Context.Service<Config, { readonly url: string }>()("Config") {}
const context = Context.make(Config, { url: "/api" })
const runnable = provideContext(fromEffect(Effect.map(Config, (x) => x.url)), context)Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.