# rxjs-protoo-client

> protoo RxJS client module

Latest version **4.0.10** (published 2020-07-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install rxjs-protoo-client
pnpm add rxjs-protoo-client
yarn add rxjs-protoo-client
bun add rxjs-protoo-client
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.10 |
| Published | 2020-07-22 |
| First published | 2020-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 2 |
| Unpacked size | 42 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kevin Wang |
| Maintainers | kevmo314 |

## Links

- npm: https://www.npmjs.com/package/rxjs-protoo-client
- Repository: https://github.com/oarli/rxjs-protoo-client
- Homepage: https://protoojs.org
- Issues: https://github.com/oarli/rxjs-protoo-client/issues
- npm.io page: https://npm.io/package/rxjs-protoo-client

## Dependencies (2)

- [rxjs](https://npm.io/package/rxjs.md) ^6.6.0
- [isomorphic-ws](https://npm.io/package/isomorphic-ws.md) ^4.0.1

## Recent versions

- 4.0.10 (latest) — 2020-07-22
- 4.0.8 — 2020-07-19
- 4.0.7 — 2020-07-17
- 4.0.6 — 2020-07-17
- 4.0.5 — 2020-07-17
- 4.0.4 — 2020-07-17

## README

# rxjs-protoo-client ![CI](https://github.com/oarli/rxjs-protoo-client/workflows/CI/badge.svg)

A [protoo](https://protoojs.org/) client written with direct RxJS support. Using RxJS results in a substantially smaller bundle size compared to the original `protoo-client`, assuming the client is also using RxJS.

## Installation

```
npm install rxjs-protoo-client
```

## Usage

```ts
import { Peer, webSocketTransport, RequestError } from "rxjs-protoo-client";

const transport = await webSocketTransport(url);

const peer = Peer.overTransport(transport);

// Send a request.
const response = await peer.request("method", {});

// Send a notification.
peer.notify("method", {});

// Listen for requests.
peer.subscribe(
  (message) => {
    if ("request" in message) {
      // Respond to the request.
      peer.next([message, {}]);

      // Alternatively, send an error.
      peer.error(new RequestError(request, 500, "Some error description."));
    } else {
      // Handle the notification.
    }
  },
  (err) => {
    // The peer unexpectedly closed.
  },
  () => {
    // The peer terminated successfully.
  }
);

// Close the connection.
peer.complete();
```

## Differences

Besides the API difference, the one difference with this library is that this library does not auto-retry unexpectedly closed connections. Instead, handle the error and re-establish the peer with a new transport manually.

---
_Source: https://npm.io/package/rxjs-protoo-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
