function / @typed/fx

RefResult.make

Creates a new RefResult from a Result, Effect, or Fx.

Package version
2.0.0-beta.13
Category
Constructors
Since
1.18.0
Member of
RefResult

Import

import { RefResult } from "@typed/fx";

Access RefResult.make through the imported RefResult export. Its declaration below describes the member.

This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.

Signatures

export declare function make<A, ResultE, Err = never, R = never>(initial: Result.Result<A, ResultE> | Effect.Effect<Result.Result<A, ResultE>, Err, R> | Fx.Fx<Result.Result<A, ResultE>, Err, R>, successEq?: Equivalence<A>, failureEq?: Equivalence<ResultE>): Effect.Effect<RefResult<A, ResultE, Err, R>, never, R | Scope.Scope>;

Why

Creates result state with equality suited to that Effect data type, so unchanged values do not produce redundant pushed updates.

Ownership and lifetime

The creation Effect requires Scope. It owns initializer acquisition, live source subscriptions, and cleanup; source failures and services stay on reads and pushes.

Examples

import { Effect, Result } from "effect"
import * as RefResult from "@typed/fx/RefResult"

const program = Effect.gen(function* () {
  const value = yield* RefResult.make(Result.succeed(42))
  const current = yield* value
  console.log(current) // { _tag: "Success", success: 42 }
})

Other public imports

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

Source