function / @typed/fx

Push.Service

Defines a named Effect service whose value is a Push.

The returned class exposes onSuccess, onFailure, and run as Effects that first resolve the service from Context. make captures the Sink construction context and combines it with each output subscriber’s context; it does not start the Fx or send an input while building the Layer.

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

Import

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

Access 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

export declare function Service<Self, A, E = never, B = never, E2 = never>(): <const Id extends string>(id: Id) => Push.Class<Self, Id, A, E, B, E2>;

Why

A service gives a bidirectional application capability one stable identity, so producers and observers can depend on it through ordinary Effect requirements.

Ownership and lifetime

The returned Layer owns service installation and captures non-Scope services needed by both sides. Output runs retain the caller’s Scope and interruption; input acknowledgment Effects run in their caller. Layer release drops the service but does not invent cleanup beyond the supplied Sink and Fx.

Examples

import { Effect, Layer } from "effect"
import * as Fx from "@typed/fx/Fx"
import * as Push from "@typed/fx/Push"
import * as Sink from "@typed/fx/Sink"

class Messages extends Push.Service<Messages, string, never, string>()("Messages") {}
const MessagesLive = Messages.make(
  Sink.make(() => Effect.void, (message) => Effect.log(message)),
  Fx.succeed("ready")
)
const send = Messages.onSuccess("hello").pipe(Effect.provide(MessagesLive))

Other public imports

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

Source