# @erebos/rpc-stream

> Stream-based RPC

Latest version **0.11.0** (published 2019-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @erebos/rpc-stream
pnpm add @erebos/rpc-stream
yarn add @erebos/rpc-stream
bun add @erebos/rpc-stream
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.11.0 |
| Published | 2019-11-28 |
| First published | 2019-10-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 12.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 48 |
| Author | Mainframe |
| Maintainers | aclarke, diogoperillo, howleysv, mosic, paul_lecam, sarahwiley |

## Links

- npm: https://www.npmjs.com/package/@erebos/rpc-stream
- Repository: https://github.com/MainframeHQ/erebos
- Homepage: https://github.com/MainframeHQ/erebos#readme
- Issues: https://github.com/MainframeHQ/erebos/issues
- npm.io page: https://npm.io/package/@erebos/rpc-stream

## Dependencies (4)

- [rxjs](https://npm.io/package/rxjs.md) ^6.5.3
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.7.4
- [@erebos/rpc-base](https://npm.io/package/@erebos/rpc-base.md) ^0.10.0
- [@erebos/rpc-error](https://npm.io/package/@erebos/rpc-error.md) ^0.10.0

## Recent versions

- 0.11.0 (latest) — 2019-11-28
- 0.10.0 — 2019-10-01

## README

# rpc-stream

Class extending [`rpc-base`](../rpc-base) to handle stateful JSON-RPC 2.0 calls.

See [`transport-ipc`](../transport-ipc), [`transport-ws-browser`](../transport-ws-browser) and [`transport-ws-node`](../transport-ws-node) for possible transports and [`rpc-request`](../rpc-request) to handle stateless JSON-RPC 2.0 calls.

## Installation

```sh
yarn add @erebos/rpc-stream
```

## Usage

```js
import StreamRPC from '@erebos/rpc-stream'
import ipcTransport from '@erebos/transport-ipc'

class MyAPI extends StreamRPC {
  constructor(path: string) {
    super(ipcTransport(path))
  }

  getUser(id: string): Promise<{ name: string }> {
    return this.request('getUser', [id])
  }
}

const api = new MyAPI('/path/to/socket')
api.getUser('1234')
```

## API

See [the `BaseRPC` API](../rpc-base/README.md#api) for inherited methods and properties.

### new StreamRPC()

**Arguments**

1.  `subject: Subject`: a [RxJS `Subject`](http://reactivex.io/rxjs/class/es6/Subject.js~Subject.html) handling communication with the server.

### .request()

**Arguments**

1.  `method: string`
1.  `params: T = any`

**Returns** `Promise<R = any>`

## License

MIT

---
_Source: https://npm.io/package/@erebos/rpc-stream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
