interface / @typed/fx

Push.Push.Service

The static and Effect service surface returned by Push.Service.

Service lookup supplies the same bidirectional value to run, onSuccess, and onFailure. The Self service appears in both required-service channels; the installed Push itself has those requirements captured by its Layer.

Package version
2.0.0-beta.7
Category
Push services
Since
1.0.0
Member of
Push.Push

Import

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

Access Push.Push.Service through the imported Push 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

interface Service<Self, Id extends string, A, E, B, E2> extends Push<A, E, Self, B, E2, Self> {
    readonly id: Id;
    readonly service: Context.Service<Self, Push<A, E, never, B, E2, never>>;
    readonly make: <R = never, R2 = never>(sink: Sink.Sink<A, E, R>, fx: Fx.Fx<B, E2, R2>) => Layer.Layer<Self, never, Exclude<R | R2, Scope.Scope>>;
}

Why

A named service lets application code send inputs and observe outputs without threading a concrete Push through every function.

Ownership and lifetime

The Layer built by make owns service installation. It captures the Sink and Fx construction contexts, excluding Scope.Scope; Scope-dependent resources must therefore be acquired by the surrounding scoped program.

Property: id

The literal Context service identifier supplied to Push.Service.

Property: id: Why

A stable literal id makes the capability identifiable in Effect Context and diagnostics without inspecting its implementation.

Property: id: Ownership and lifetime

The id is immutable metadata and owns no resource.

Property: make

Builds a Layer that installs a concrete Sink/Fx pair as this service.

Building the Layer starts neither side. The Sink context is captured at Layer construction; each output run additionally receives its subscriber’s context.

Property: make: Why

The Layer is the explicit composition boundary between implementation requirements and consumers that depend only on Self.

Property: make: Ownership and lifetime

Layer lifetime owns service installation. Scope.Scope is excluded from captured requirements so scoped resources remain owned by the surrounding scoped Effect.

Property: service

The Effect Context service used by the static Push operations.

Property: service: Why

Exposing the Context service permits ordinary Effect service composition in addition to the convenience statics.

Property: service: Ownership and lifetime

This is an immutable service reference. The Layer providing Self, not the reference, owns installation and release.

Examples

import * as Push from "@typed/fx/Push"

class Events extends Push.Service<Events, string, never, string>()("Events") {}
const id: "Events" = Events.id
import * as Push from "@typed/fx/Push"
class Events extends Push.Service<Events, string, never, string>()("Events") {}
const id: "Events" = Events.id
import { Effect } from "effect"
import * as Fx from "@typed/fx/Fx"
import * as Push from "@typed/fx/Push"
import * as Sink from "@typed/fx/Sink"
class Events extends Push.Service<Events, string, never, string>()("Events") {}
const Live = Events.make(Sink.make(() => Effect.void, () => Effect.void), Fx.succeed("ready"))
import * as Push from "@typed/fx/Push"
class Events extends Push.Service<Events, string, never, string>()("Events") {}
const service = Events.service

Other public imports

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

Source