# make

Acquires a `Subject` whose subscribers and replay state are released with the current `Scope`.

## Signatures

```ts
export declare function make<A, E = never>(replay?: number): Effect.Effect<Subject<A, E>, Cause.IllegalArgumentError, Scope.Scope>;
```

## Why

`make` places the imperative subject boundary under Effect's structured resource ownership, so
cancellation and scope closure cannot leave subscriptions or retained values behind.

## Ownership and lifetime

The effect allocates when executed, not when described. Its required `Scope` installs a finalizer
that runs `interrupt`, closing all subscriber scopes and clearing the replay buffer. Individual
subscriber scopes may still end earlier without affecting other subscribers.

## Errors

Invalid capacities fail in the typed error channel with `Cause.IllegalArgumentError`; no subject
is allocated. Once acquired, publication callbacks have no typed failure result; the subject's
`E` parameter describes incoming Causes rather than publication acknowledgment errors.
Interruption and defects remain distinct from that typed channel.

## Examples

```ts
import { Effect } from "effect"
import * as Subject from "@typed/fx/Subject"

const program = Effect.gen(function* () {
  const messages = yield* Subject.make<string>(1)
  yield* messages.onSuccess("online")
  return yield* messages.subscriberCount
}).pipe(Effect.scoped)
```
