Skip to main content Link Search Menu Expand Document (external link)

Supervisor overview

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

Added in v2.0.0


Table of contents


constructors

AbstractSupervisor (class)

Signature

export declare class AbstractSupervisor<T>

Added in v2.0.0

onStart (method)

Signature

onStart<A, E, R>(
    _context: Context.Context<R>,
    _effect: Effect.Effect<A, E, R>,
    _parent: Option.Option<Fiber.RuntimeFiber<any, any>>,
    _fiber: Fiber.RuntimeFiber<A, E>
  ): void

Added in v2.0.0

onEnd (method)

Signature

onEnd<A, E>(
    _value: Exit.Exit<A, E>,
    _fiber: Fiber.RuntimeFiber<A, E>
  ): void

Added in v2.0.0

onEffect (method)

Signature

onEffect<A, E>(
    _fiber: Fiber.RuntimeFiber<A, E>,
    _effect: Effect.Effect<any, any, any>
  ): void

Added in v2.0.0

onSuspend (method)

Signature

onSuspend<A, E>(
    _fiber: Fiber.RuntimeFiber<A, E>
  ): void

Added in v2.0.0

onResume (method)

Signature

onResume<A, E>(
    _fiber: Fiber.RuntimeFiber<A, E>
  ): void

Added in v2.0.0

map (method)

Signature

map<B>(f: (a: T) => B): Supervisor<B>

Added in v2.0.0

zip (method)

Signature

zip<A>(
    right: Supervisor<A>
  ): Supervisor<[T, A]>

Added in v2.0.0

onRun (method)

Signature

onRun<E, A, X>(execution: () => X, _fiber: Fiber.RuntimeFiber<A, E>): X

Added in v2.0.0

value (property)

Signature

value: Effect.Effect<T, never, never>

Added in v2.0.0

[SupervisorTypeId] (property)

Signature

readonly [SupervisorTypeId]: { _T: (_: never) => never; }

Added in v2.0.0

fibersIn

Creates a new supervisor that tracks children in a set.

Signature

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

Added in v2.0.0

fromEffect

Creates a new supervisor that constantly yields effect when polled

Signature

export declare const fromEffect: <A>(effect: Effect.Effect<A, never, never>) => Supervisor<A>

Added in v2.0.0

none

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

Signature

export declare const none: Supervisor<void>

Added in v2.0.0

track

Creates a new supervisor that tracks children in a set.

Signature

export declare const track: Effect.Effect<Supervisor<Fiber.RuntimeFiber<any, any>[]>, never, never>

Added in v2.0.0

context

addSupervisor

Signature

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

Added in v2.0.0

models

Supervisor (interface)

Signature

export interface Supervisor<out T> extends Supervisor.Variance<T> {
  /**
   * Returns an `Effect` that succeeds with the value produced by this
   * supervisor. This value may change over time, reflecting what the supervisor
   * produces as it supervises fibers.
   */
  readonly value: Effect.Effect<T>

  /**
   * Supervises the start of a `Fiber`.
   */
  onStart<A, E, R>(
    context: Context.Context<R>,
    effect: Effect.Effect<A, E, R>,
    parent: Option.Option<Fiber.RuntimeFiber<any, any>>,
    fiber: Fiber.RuntimeFiber<A, E>
  ): void

  /**
   * Supervises the end of a `Fiber`.
   */
  onEnd<A, E>(value: Exit.Exit<A, E>, fiber: Fiber.RuntimeFiber<A, E>): void

  /**
   * Supervises the execution of an `Effect` by a `Fiber`.
   */
  onEffect<A, E>(fiber: Fiber.RuntimeFiber<A, E>, effect: Effect.Effect<any, any, any>): void

  /**
   * Supervises the suspension of a computation running within a `Fiber`.
   */
  onSuspend<A, E>(fiber: Fiber.RuntimeFiber<A, E>): void

  /**
   * Supervises the resumption of a computation running within a `Fiber`.
   */
  onResume<A, E>(fiber: Fiber.RuntimeFiber<A, E>): void

  /**
   * Maps this supervisor to another one, which has the same effect, but whose
   * value has been transformed by the specified function.
   */
  map<B>(f: (a: T) => B): Supervisor<B>

  /**
   * Returns a new supervisor that performs the function of this supervisor, and
   * the function of the specified supervisor, producing a tuple of the outputs
   * produced by both supervisors.
   */
  zip<A>(right: Supervisor<A>): Supervisor<[T, A]>
}

Added in v2.0.0

symbols

SupervisorTypeId

Signature

export declare const SupervisorTypeId: typeof SupervisorTypeId

Added in v2.0.0

SupervisorTypeId (type alias)

Signature

export type SupervisorTypeId = typeof SupervisorTypeId

Added in v2.0.0

unsafe

unsafeTrack

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

Signature

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

Added in v2.0.0

utils

Supervisor (namespace)

Added in v2.0.0

Variance (interface)

Signature

export interface Variance<out T> {
  readonly [SupervisorTypeId]: {
    readonly _T: Types.Covariant<T>
  }
}

Added in v2.0.0