Skip to content

Supervisor

A Supervisor<T> is allowed to supervise the launching and termination of fibers, producing some visible value of type T from the supervision.

11 exports Added in v2.0.0 Source

Constructors

Signature

declare class AbstractSupervisor<T> implements Supervisor<T> {
  constructor<T>();
  readonly [SupervisorTypeId]: {
    _T: (_: never) => never;
  };
  abstract value: Effect<T>;
  map<B>(f: (a: T) => B): Supervisor<B>;
  onEffect<A, E>(_fiber: RuntimeFiber<A, E>, _effect: Effect<any, any, any>): void;
  onEnd<A, E>(_value: Exit<A, E>, _fiber: RuntimeFiber<A, E>): void;
  onResume<A, E>(_fiber: RuntimeFiber<A, E>): void;
  onRun<E, A, X>(execution: () => X, _fiber: RuntimeFiber<A, E>): X;
  onStart<A, E, R>(_context: Context<R>, _effect: Effect<A, E, R>, _parent: Option<RuntimeFiber<any, any>>, _fiber: RuntimeFiber<A, E>): void;
  onSuspend<A, E>(_fiber: RuntimeFiber<A, E>): void;
  zip<A>(right: Supervisor<A>): Supervisor<[T, A]>;
}

fibersIn

Added in v2.0.0 Source

Creates a new supervisor that tracks children in a set.

Signature

declare const fibersIn: (
  ref: MutableRef.MutableRef<SortedSet.SortedSet<Fiber.RuntimeFiber<any, any>>>,
) => Effect.Effect<Supervisor<SortedSet.SortedSet<Fiber.RuntimeFiber<any, any>>>>;

fromEffect

Added in v2.0.0 Source

Creates a new supervisor that constantly yields effect when polled

Signature

declare const fromEffect: <A>(effect: Effect.Effect<A>) => Supervisor<A>;

none

Added in v2.0.0 Source

A supervisor that doesn't do anything in response to supervision events.

Signature

declare const none: Supervisor<void>;

track

Added in v2.0.0 Source

Creates a new supervisor that tracks children in a set.

Signature

declare const track: Effect.Effect<Supervisor<Array<Fiber.RuntimeFiber<any, any>>>>;

Context

Signature

declare const addSupervisor: <A>(supervisor: Supervisor<A>) => Layer.Layer<never>;

Models

Supervisor interface

Added in v2.0.0 Source

Signature

interface Supervisor<out T> extends Variance<T> {
  readonly value: Effect<T>;
  map<B>(f: (a: T) => B): Supervisor<B>;
  onEffect<A, E>(fiber: RuntimeFiber<A, E>, effect: Effect<any, any, any>): void;
  onEnd<A, E>(value: Exit<A, E>, fiber: RuntimeFiber<A, E>): void;
  onResume<A, E>(fiber: RuntimeFiber<A, E>): void;
  onStart<A, E, R>(
    context: Context<R>,
    effect: Effect<A, E, R>,
    parent: Option<RuntimeFiber<any, any>>,
    fiber: RuntimeFiber<A, E>,
  ): void;
  onSuspend<A, E>(fiber: RuntimeFiber<A, E>): void;
  zip<A>(right: Supervisor<A>): Supervisor<[T, A]>;
}

Other

Supervisor

Added in v2.0.0 Source

Symbols

Signature

declare const SupervisorTypeId: unique symbol;

SupervisorTypeId type

Added in v2.0.0 Source

Signature

type SupervisorTypeId = typeof SupervisorTypeId;

Unsafe

unsafeTrack

Added in v2.0.0 Source

Unsafely creates a new supervisor that tracks children in a set.

Signature

declare const unsafeTrack: () => Supervisor<Array<Fiber.RuntimeFiber<any, any>>>;