# ServiceDefinition

Source: /tuil/docs/reference/packages/core/api/service-definition
Locale: en

interface exported by @mwillbanks/tuil-core.



{/* Generated by tooling/docs/generate-reference.ts. */}

## interface [#interface]

Public interface exported by `@mwillbanks/tuil-core`.

```ts
export interface ServiceDefinition<
  TId extends string = string,
  TValue = unknown,
> {
  readonly id: TId;
  readonly create: (context: ServiceFactoryContext) => TValue | Promise<TValue>;
  readonly dispose?: (value: TValue) => void | Promise<void>;
}
```

## Members [#members]

| Member    | Type                                                            | Required | Description                                                                                            | Related types                                                                        |
| --------- | --------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| `id`      | `TId`                                                           | Yes      | The `id` member uses the `TId` contract.                                                               | —                                                                                    |
| `create`  | `(context: ServiceFactoryContext) => TValue \| Promise<TValue>` | Yes      | The `create` member uses the `(context: ServiceFactoryContext) => TValue \| Promise<TValue>` contract. | [`ServiceFactoryContext`](/tuil/docs/reference/packages/core/api/service-factory-context) |
| `dispose` | `((value: TValue) => void \| Promise<void>) \| undefined`       | No       | The `dispose` member uses the `((value: TValue) => void \| Promise<void>) \| undefined` contract.      | —                                                                                    |

## Parameters [#parameters]

This declaration has no public members.

## Returns [#returns]

This declaration does not return a value.

## Throws [#throws]

No thrown errors are documented for this declaration.

## Related types [#related-types]

* [`ServiceFactoryContext`](/tuil/docs/reference/packages/core/api/service-factory-context)

## Source [#source]

[View the secondary source reference](https://github.com/mwillbanks/tuil/blob/main/packages/core/src/services.ts)

## Package [#package]

[@mwillbanks/tuil-core](/tuil/docs/reference/packages/core)
