

# Emitter

<div class="api-docs__separator" data-reactroot="">

---

</div><div class="api-docs__import" data-reactroot="">

```ts
import { Emitter } from "@hyper-fetch/sockets"
```

</div><div class="api-docs__section">

## Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:8](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L8)

</p><div class="api-docs__section">

## Parameters

</div><div class="api-docs__parameters"><table><thead><tr><th>Name</th><th>Details</th></tr></thead><tbody><tr param-data="socket"><td class="api-docs__param-name required">

### socket 

`Required`

</td><td class="api-docs__param-type">

`Socket<Adapter>`

</td></tr><tr param-data="emitterOptions"><td class="api-docs__param-name required">

### emitterOptions 

`Required`

</td><td class="api-docs__param-type">

`EmitterOptionsType<ExtractEmitterOptionsType<Adapter>>`

</td></tr><tr param-data="json"><td class="api-docs__param-name optional">

### json 

`Optional`

</td><td class="api-docs__param-type">

`Partial<Emitter<Payload, Response, Adapter, MappedData>>`

</td></tr><tr param-data="dataMapper"><td class="api-docs__param-name optional">

### dataMapper 

`Optional`

</td><td class="api-docs__param-type">

`(data: Payload) => MappedData`

</td></tr></tbody></table></div><div class="api-docs__section">

## Properties

</div><div class="api-docs__properties"><div class="api-docs__property" property-data="data"><h3 class="api-docs__name">

### `data`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:11](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L11)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
Payload
```

</div><hr/></div><div class="api-docs__property" property-data="emitterOptions"><h3 class="api-docs__name">

### `emitterOptions`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:16](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L16)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
EmitterOptionsType<ExtractEmitterOptionsType<Adapter>>
```

</div><hr/></div><div class="api-docs__property" property-data="name"><h3 class="api-docs__name">

### `name`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:9](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L9)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
string
```

</div><hr/></div><div class="api-docs__property" property-data="options"><h3 class="api-docs__name">

### `options`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:12](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L12)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
ExtractEmitterOptionsType<Adapter>
```

</div><hr/></div><div class="api-docs__property" property-data="socket"><h3 class="api-docs__name">

### `socket`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:15](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L15)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
Socket<Adapter>
```

</div><hr/></div><div class="api-docs__property" property-data="timeout"><h3 class="api-docs__name">

### `timeout`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:10](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L10)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
number
```

</div><hr/></div></div><div class="api-docs__section">

## Methods

</div><div class="api-docs__methods"><div class="api-docs__method" method-data="dataMapper"><h3 class="api-docs__name">

### `dataMapper()`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:18](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L18)

</p><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
(data: Payload) => MappedData
```

</div><hr/></div><div class="api-docs__method" method-data="clone"><h3 class="api-docs__name">

### `clone()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
clone<NewPayload, MapperData>(config, mapper)
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:46](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L46)

</p><div class="api-docs__section">

#### Parameters

</div><div class="api-docs__parameters"><table><thead><tr><th>Name</th><th>Details</th></tr></thead><tbody><tr param-data="config"><td class="api-docs__param-name optional">

#### config 

`Optional`

</td><td class="api-docs__param-type">

`Partial<EmitterCloneOptionsType<NewPayload, ExtractEmitterOptionsType<Adapter>>>`

</td></tr><tr param-data="mapper"><td class="api-docs__param-name optional">

#### mapper 

`Optional`

</td><td class="api-docs__param-type">

`(data: NewPayload) => MapperData`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
Emitter<NewPayload, Response, Adapter, MapperData>
```

</div><hr/></div><div class="api-docs__method" method-data="emit"><h3 class="api-docs__name">

### `emit()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
emit(options, ack)
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:62](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L62)

</p><div class="api-docs__section">

#### Parameters

</div><div class="api-docs__parameters"><table><thead><tr><th>Name</th><th>Details</th></tr></thead><tbody><tr param-data="options"><td class="api-docs__param-name optional">

#### options 

`Optional`

</td><td class="api-docs__param-type">

`Partial<EmitterCloneOptionsType<Payload, ExtractEmitterOptionsType<Adapter>>>`

</td></tr><tr param-data="ack"><td class="api-docs__param-name optional">

#### ack 

`Optional`

</td><td class="api-docs__param-type">

`(error: Error, response: Response) => void`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
string
```

</div><hr/></div><div class="api-docs__method" method-data="setData"><h3 class="api-docs__name">

### `setData()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
setData(data)
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:35](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L35)

</p><div class="api-docs__section">

#### Parameters

</div><div class="api-docs__parameters"><table><thead><tr><th>Name</th><th>Details</th></tr></thead><tbody><tr param-data="data"><td class="api-docs__param-name required">

#### data 

`Required`

</td><td class="api-docs__param-type">

`Payload`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
Emitter<Payload, Response, Adapter, MappedData>
```

</div><hr/></div><div class="api-docs__method" method-data="setDataMapper"><h3 class="api-docs__name">

### `setDataMapper()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
setDataMapper<MapperData>(mapper)
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:42](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L42)

</p><div class="api-docs__section">

#### Parameters

</div><div class="api-docs__parameters"><table><thead><tr><th>Name</th><th>Details</th></tr></thead><tbody><tr param-data="mapper"><td class="api-docs__param-name required">

#### mapper 

`Required`

</td><td class="api-docs__param-type">

`(data: Payload) => MapperData`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
Emitter<Payload, Response, Adapter, MapperData>
```

</div><hr/></div><div class="api-docs__method" method-data="setOptions"><h3 class="api-docs__name">

### `setOptions()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
setOptions(options)
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:27](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L27)

</p><div class="api-docs__section">

#### Parameters

</div><div class="api-docs__parameters"><table><thead><tr><th>Name</th><th>Details</th></tr></thead><tbody><tr param-data="options"><td class="api-docs__param-name required">

#### options 

`Required`

</td><td class="api-docs__param-type">

`ExtractEmitterOptionsType<Adapter>`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
Emitter<Payload, Response, Adapter, MappedData>
```

</div><hr/></div><div class="api-docs__method" method-data="setTimeout"><h3 class="api-docs__name">

### `setTimeout()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
setTimeout(timeout)
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">



</span></div><p class="api-docs__definition">

Defined in [emitter/emitter.ts:31](https://github.com/BetterTyped/hyper-fetch/blob/c44d728f/packages/sockets/src/emitter/emitter.ts#L31)

</p><div class="api-docs__section">

#### Parameters

</div><div class="api-docs__parameters"><table><thead><tr><th>Name</th><th>Details</th></tr></thead><tbody><tr param-data="timeout"><td class="api-docs__param-name required">

#### timeout 

`Required`

</td><td class="api-docs__param-type">

`number`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
Emitter<Payload, Response, Adapter, MappedData>
```

</div><hr/></div></div>