# Subject.Subject.Service

The service-shaped form of a `Subject` created by `Subject.Service`.

## Signatures

```ts
interface Service<Self, Id extends string, A, E> extends Subject<A, E, Self> {
    readonly id: Id;
    readonly service: Context.Service<Self, Subject<A, E>>;
    readonly make: (replay?: number) => Layer.Layer<Self, Cause.IllegalArgumentError, Scope.Scope>;
}
```

## Why

A service form lets producers and consumers refer to one shared subject through Effect's
context instead of passing the concrete instance through every call.

## Ownership and lifetime

Static Subject operations require `Self` and delegate to the instance installed by `make`.
The layer owns that instance in a `Scope` and interrupts it when the layer is released.

## Property: id

The literal context identifier supplied to `Subject.Service`.

## Property: id: Why

Preserves the service's stable identity for diagnostics and layer composition.

## Property: id: Ownership and lifetime

This string literal acquires and retains no resources.

## Property: make

Builds a scoped layer containing one subject with the requested replay capacity.

## Property: make: Why

Packages one shared subject as a normal Effect layer for dependency composition.

## Property: make: Ownership and lifetime

Invalid capacities fail layer construction with `Cause.IllegalArgumentError`. The layer's
scope owns the subject and interrupts its subscribers and clears its replay buffer on release.

## Property: service

The Effect context service used to retrieve the live subject instance.

## Property: service: Why

Provides the standard Effect service lookup used by every static Subject operation.

## Property: service: Ownership and lifetime

The tag acquires nothing; the layer installed for it owns the concrete subject.

## Examples

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

class Events extends Subject.Service<Events, string>()("Events") {}
const EventsLive = Events.make()
```

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

class Events extends Subject.Service<Events, string>()("Events") {}
const EventsLive = Events.make(1)
```
