function / @typed/fx/RefSubject

tuple

Combines multiple RefSubject, Computed, or Filtered instances into a single tuple.

Package version
2.0.0-beta.13
Category
State composition
Since
1.0.0

Import

import { tuple } from "@typed/fx/RefSubject";

Signatures

export declare function tuple<const Refs extends ReadonlyArray<Ref>>(refs: Refs): TupleFrom<Refs>;

Why

Combines several refs into one state value while preserving whether the result is writable, computed, or filtered from its inputs.

Ownership and lifetime

This declaration performs no acquisition and retains no resources. Implementations preserve source errors, services, and lifetime.

Examples

import { Effect } from "effect"
import * as RefSubject from "@typed/fx/RefSubject"

const program = Effect.gen(function* () {
  const x = yield* RefSubject.make(10)
  const y = yield* RefSubject.make(20)
  const z = yield* RefSubject.make(30)

  // Combine into a tuple
  const point = RefSubject.tuple([x, y, z])

  const coords = yield* point
  console.log(coords) // [10, 20, 30]

  // Update one value
  yield* RefSubject.set(x, 15)

  // Tuple automatically updates
  const updated = yield* point
  console.log(updated) // [15, 20, 30]
})

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source