# Stream

**Kind**: interface | **Module**: [Interop](https://docs.interop.io/desktop/reference/javascript/interop/index.md)

**Source**: https://docs.interop.io/desktop/reference/javascript/interop/stream/index.html

Object describing an Interop stream.

## Properties

- **`definition`** (`MethodDefinition`, required)
  Stream definition object.
- **`name`** (`string`, required)
  Name of the stream.

## Methods

### branch

Returns a branch by key.

```ts
(key: string) => StreamBranch | undefined
```

**Parameters**

- **`key`** (`string`, required)

**Returns**: `StreamBranch | undefined`

### branches

Returns the list of available stream branches.

```ts
() => StreamBranch[]
```

**Returns**: `StreamBranch[]`

### branches

```ts
(key: string) => StreamBranch | undefined
```

**Parameters**

- **`key`** (`string`, required)

**Returns**: `StreamBranch | undefined`

### branches

```ts
(key?: string) => StreamBranch | StreamBranch[] | undefined
```

**Parameters**

- **`key`** (`string`, optional)

**Returns**: `StreamBranch | StreamBranch[] | undefined`

### close

Closes the stream. This will close all subscriptions.

```ts
() => void
```

**Returns**: `void`

### push

Push data to the stream. If a `branches` argument is passed, the data will be sent to the specified stream branch(es) only.

```ts
(data: object, branches?: string | string[]) => void
```

**Parameters**

- **`data`** (`object`, required)
  Data to push.
- **`branches`** (`string | string[]`, optional)
  To which branch(es) to push data.

**Returns**: `void`

### subscriptions

Returns a list of active subscriptions to the stream.

```ts
() => StreamSubscription[]
```

**Returns**: `StreamSubscription[]`

## Related types

- [MethodDefinition](https://docs.interop.io/desktop/reference/javascript/interop/methoddefinition/index.md)
- [StreamBranch](https://docs.interop.io/desktop/reference/javascript/interop/streambranch/index.md)
- [StreamSubscription](https://docs.interop.io/desktop/reference/javascript/interop/streamsubscription/index.md)
