Skip to content

FiberRefs

14 exports Added in v2.0.0 Source

Constructors

empty

Added in v2.0.0 Source

The empty collection of FiberRef values.

Signature

declare const empty: () => FiberRefs;

Getters

fiberRefs

Added in v2.0.0 Source

Returns a set of each FiberRef in this collection.

Signature

declare const fiberRefs: (self: FiberRefs) => HashSet.HashSet<FiberRef.FiberRef<any>>;

get

Added in v2.0.0 Source

Gets the value of the specified FiberRef in this collection of FiberRef values if it exists or None otherwise.

Signature

declare const get: {
  <A>(fiberRef: FiberRef<A>): (self: FiberRefs) => Option<A>;
  <A>(self: FiberRefs, fiberRef: FiberRef<A>): Option<A>;
};

getOrDefault

Added in v2.0.0 Source

Gets the value of the specified FiberRef in this collection of FiberRef values if it exists or the initial value of the FiberRef otherwise.

Signature

declare const getOrDefault: {
  <A>(fiberRef: FiberRef<A>): (self: FiberRefs) => A;
  <A>(self: FiberRefs, fiberRef: FiberRef<A>): A;
};

Models

FiberRefs interface

Added in v2.0.0 Source

FiberRefs is a data type that represents a collection of FiberRef values.

This allows safely propagating FiberRef values across fiber boundaries, for example between an asynchronous producer and consumer.

Signature

interface FiberRefs extends Pipeable {
  readonly [FiberRefsSym]: typeof FiberRefsSym;
  readonly locals: Map<FiberRef<any>, readonly [readonly [Single, any], readonly [Single, any]]>;
}

Other

Signature

declare const delete: {
  <A>(fiberRef: FiberRef<A>): (self: FiberRefs) => FiberRefs;
  <A>(self: FiberRefs, fiberRef: FiberRef<A>): FiberRefs;
}

Symbols

FiberRefsSym

Added in v2.0.0 Source

Signature

declare const FiberRefsSym: unique symbol;

FiberRefsSym type

Added in v2.0.0 Source

Signature

type FiberRefsSym = typeof FiberRefsSym;

Unsafe

unsafeMake

Added in v2.0.0 Source

Note: it will not copy the provided Map, make sure to provide a fresh one.

Signature

declare const unsafeMake: (
  fiberRefLocals: Map<
    FiberRef.FiberRef<any>,
    Arr.NonEmptyReadonlyArray<readonly [FiberId.Single, any]>
  >,
) => FiberRefs;

Utils

forkAs

Added in v2.0.0 Source

Forks this collection of fiber refs as the specified child fiber id. This will potentially modify the value of the fiber refs, as determined by the individual fiber refs that make up the collection.

Signature

declare const forkAs: {
  (childId: Single): (self: FiberRefs) => FiberRefs;
  (self: FiberRefs, childId: Single): FiberRefs;
};

joinAs

Added in v2.0.0 Source

Joins this collection of fiber refs to the specified collection, as the specified fiber id. This will perform diffing and merging to ensure preservation of maximum information from both child and parent refs.

Signature

declare const joinAs: {
  (fiberId: Single, that: FiberRefs): (self: FiberRefs) => FiberRefs;
  (self: FiberRefs, fiberId: Single, that: FiberRefs): FiberRefs;
};

setAll

Added in v2.0.0 Source

Set each ref to either its value or its default.

Signature

declare const setAll: (self: FiberRefs) => Effect.Effect<void>;

updateAs

Added in v2.0.0 Source

Updates the value of the specified FiberRef using the provided FiberId

Signature

declare const updateAs: {
  <A>(options: {
    readonly fiberId: FiberId.Single;
    readonly fiberRef: FiberRef.FiberRef<A>;
    readonly value: A;
  }): (self: FiberRefs) => FiberRefs;
  <A>(
    self: FiberRefs,
    options: {
      readonly fiberId: FiberId.Single;
      readonly fiberRef: FiberRef.FiberRef<A>;
      readonly value: A;
    },
  ): FiberRefs;
};

updateManyAs

Added in v2.0.0 Source

Updates the values of the specified FiberRef & value pairs using the provided FiberId

Signature

declare const updateManyAs: {
  (options: {
    readonly entries: readonly [readonly [FiberRef.FiberRef<any>, readonly [readonly [FiberId.Single, any], ...Array<readonly ...>]], ...Array<readonly [FiberRef.FiberRef<any>, readonly [readonly ..., ......]]>];
    readonly forkAs?: FiberId.Single;
  }): (self: FiberRefs) => FiberRefs;
  (self: FiberRefs, options: {
    readonly entries: readonly [readonly [FiberRef.FiberRef<any>, readonly [readonly [FiberId.Single, any], ...Array<readonly ...>]], ...Array<readonly [FiberRef.FiberRef<any>, readonly [readonly ..., ......]]>];
    readonly forkAs?: FiberId.Single;
  }): FiberRefs;
}