interface / @typed/fx/Fx

Fx.Class

The constructible service class returned by Fx.Service.

Package version
2.0.0-beta.13
Category
models
Since
1.0.0
Member of
Fx

Import

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

Access Fx.Class through the imported Fx export. Its declaration below describes the member.

Signatures

interface Class<Self, Id extends string, A, E> extends Service<Self, Id, A, E> {
    new (): Service<Self, Id, A, E>;
}

Why

A single value can act as the service tag, the service-backed Fx, and the owner of its Layer constructor, matching Effect’s class-based service ergonomics.

Ownership and lifetime

Constructing the class returns the class value and starts no producer. Installed layer scopes own actual implementations.

Construct signatures

Returns the service class as its service-backed Fx value.

Construct signatures: Why

Supports Effect’s class-as-tag ergonomics without allocating wrapper instances.

Construct signatures: Ownership and lifetime

Construction starts no producer. The installed layer owns the implementation.

Examples

import { Fx } from "@typed/fx"
import type { Fx as FxModel } from "@typed/fx/Fx"

class Ticks extends Fx.Service<Ticks, number>()("app/Ticks") {}
const definition: FxModel.Class<Ticks, "app/Ticks", number, never> = Ticks

Other public imports

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

Source