# Service

Defines an Effect service whose value is also a directly runnable `Fx`.

## Signatures

```ts
export declare function Service<Self, A, E = never>(): <const Id extends string>(id: Id) => Fx.Class<Self, Id, A, E>;
```

## Why

Applications often need a producer selected by the Effect environment: a clock,
event source, transport, or domain feed. `Service` keeps that dependency in `R`
and provides the corresponding layer constructor without a parallel wrapper API.

## Ownership and lifetime

Defining the class starts no work. `Class.make` acquires the producer when its layer
is built, supplies the acquisition context to it, and binds its lifetime to the
layer scope. Running the class reads the currently installed implementation.

## Examples

```ts
import { Effect, Layer } from "effect"
import { Fx } from "@typed/fx"

class Ticks extends Fx.Service<Ticks, number>()("app/Ticks") {}

const TicksLive = Ticks.make(Fx.succeed(1))
const values = Fx.collectAll(Ticks).pipe(Effect.provide(TicksLive))
const program = Effect.map(values, (items) => items[0])
```
