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

FiberRefs overview

Added in v2.0.0


Table of contents


constructors

empty

The empty collection of FiberRef values.

Signature

export declare const empty: () => FiberRefs

Added in v2.0.0

getters

fiberRefs

Returns a set of each FiberRef in this collection.

Signature

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

Added in v2.0.0

get

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

Signature

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

Added in v2.0.0

getOrDefault

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

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

Added in v2.0.0

models

FiberRefs (interface)

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

export interface FiberRefs extends Pipeable {
  readonly [FiberRefsSym]: FiberRefsSym
  readonly locals: Map<FiberRef.FiberRef<any>, Arr.NonEmptyReadonlyArray<readonly [FiberId.Single, any]>>
}

Added in v2.0.0

symbols

FiberRefsSym

Signature

export declare const FiberRefsSym: typeof FiberRefsSym

Added in v2.0.0

FiberRefsSym (type alias)

Signature

export type FiberRefsSym = typeof FiberRefsSym

Added in v2.0.0

unsafe

unsafeMake

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

Signature

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

Added in v2.0.0

utils

delete

Deletes the specified FiberRef from the FibterRefs.

Signature

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

Added in v2.0.0

forkAs

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

export declare const forkAs: {
  (childId: FiberId.Single): (self: FiberRefs) => FiberRefs
  (self: FiberRefs, childId: FiberId.Single): FiberRefs
}

Added in v2.0.0

joinAs

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

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

Added in v2.0.0

setAll

Set each ref to either its value or its default.

Signature

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

Added in v2.0.0

updateAs

Updates the value of the specified FiberRef using the provided FiberId

Signature

export 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
}

Added in v2.0.0

updateManyAs

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

Signature

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

Added in v2.0.0