Import
import { Computed } from "@typed/fx/RefSubject";Signatures
export interface Computed<out A, out E = never, out R = never> extends Versioned.Versioned<R, E, A, E, R | Scope.Scope, A, E, R> {
readonly [ComputedTypeId]: ComputedTypeId;
}export declare namespace Computed {
type Any = Computed<any, any, any> | Computed<never, any, any> | Computed<any, never, any> | Computed<never, never, any>;
}Why
Represents derived state as both an Effectful current read and an Fx of subsequent versions, without granting write access.
Ownership and lifetime
Computed is a contract and performs no acquisition. Implementations retain the errors, services, interruption, and Scope requirements expressed by its members.
Property: [[computed:[ComputedTypeId]]]
Carries the runtime marker recognized by isComputed.
Property: [[computed:[ComputedTypeId]]]: Why
Marks the value as Computed for runtime guards and composition without granting writable RefSubject operations.
Property: [[computed:[ComputedTypeId]]]: 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 { RefSubject } from "@typed/fx"
import { Fx } from "@typed/fx"
// Create a RefSubject and derive a Computed from it
const program = Effect.gen(function* () {
const count = yield* RefSubject.make(0)
// Create a computed that doubles the count
const doubled = RefSubject.map(count, (n) => n * 2)
// Sample the computed value
const value = yield* doubled
console.log(value) // 0
// Update the source
yield* RefSubject.set(count, 5)
// The computed automatically reflects the change
const newValue = yield* doubled
console.log(newValue) // 10
})Members
Computed.AnyDescribes the any type.
Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.