

# Listener

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

---

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

```ts
import { Listener } 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 [listener/listener.ts:6](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/listener/listener.ts#L6)

</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<ClientType>`

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

### listenerOptions 

`Optional`

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

`ListenerOptionsType<ExtractListenerOptionsType<ClientType>>`

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

## Properties

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

### `listenerOptions`

</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 [listener/listener.ts:12](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/listener/listener.ts#L12)

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

#### Type

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

```ts
ListenerOptionsType<ExtractListenerOptionsType<ClientType>>
```

</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 [listener/listener.ts:7](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/listener/listener.ts#L7)

</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 [listener/listener.ts:8](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/listener/listener.ts#L8)

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

#### Type

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

```ts
ExtractListenerOptionsType<ClientType>
```

</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 [listener/listener.ts:11](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/listener/listener.ts#L11)

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

#### Type

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

```ts
Socket<ClientType>
```

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

## Methods

</div><div class="api-docs__methods"><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(config)
```

</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 [listener/listener.ts:23](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/listener/listener.ts#L23)

</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<ListenerOptionsType<ExtractListenerOptionsType<ClientType>>>`

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

#### Return

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

```ts
Listener<ResponseType, ClientType>
```

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

### `listen()`

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

#### Preview

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

```ts
listen(callback)
```

</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 [listener/listener.ts:33](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/listener/listener.ts#L33)

</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="callback"><td class="api-docs__param-name required">

#### callback 

`Required`

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

`(data: ListenerCallbackType<ResponseType>) => void`

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

#### Return

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

```ts
readonly [() => void, (data: ListenerCallbackType<ResponseType>) => void]
```

</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 [listener/listener.ts:19](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/listener/listener.ts#L19)

</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">

`ExtractListenerOptionsType<ClientType>`

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

#### Return

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

```ts
Listener<ResponseType, ClientType>
```

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