# 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.

## Signatures

```ts
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

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

class Events extends Push.Service<Events, string, never, string>()("Events") {}
const id: "Events" = Events.id
```

```ts
import * as Push from "@typed/fx/Push"
class Events extends Push.Service<Events, string, never, string>()("Events") {}
const id: "Events" = Events.id
```

```ts
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"))
```

```ts
import * as Push from "@typed/fx/Push"
class Events extends Push.Service<Events, string, never, string>()("Events") {}
const service = Events.service
```
