# rxjs-ws

> Ping/Pong example: ```ts const client = new RXSocketClient({ url: 'ws://localhost:3000' }); const pingEvent = client.event('ping'); pingEvent.subscribe((response) => pingEvent.send());

Latest version **1.0.6** (published 2024-08-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install rxjs-ws
pnpm add rxjs-ws
yarn add rxjs-ws
bun add rxjs-ws
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2024-08-14 |
| First published | 2021-05-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 26.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Luke265 |
| Maintainers | luke265 |

## Links

- npm: https://www.npmjs.com/package/rxjs-ws
- Repository: https://github.com/Luke265/rxjs-ws
- Homepage: https://github.com/Luke265/rxjs-ws#readme
- Issues: https://github.com/Luke265/rxjs-ws/issues
- npm.io page: https://npm.io/package/rxjs-ws

## Dependencies (3)

- [ws](https://npm.io/package/ws.md) >=6
- [rxjs](https://npm.io/package/rxjs.md) >=6
- [tslib](https://npm.io/package/tslib.md) >=1.0.0

## Recent versions

- 1.0.6 (latest) — 2024-08-14
- 1.0.5 — 2023-01-09
- 1.0.4 — 2023-01-09
- 1.0.3 — 2021-12-03
- 1.0.2 — 2021-06-03
- 1.0.1 — 2021-05-27

## README

Ping/Pong example:
```ts
const client = new RXSocketClient({ url: 'ws://localhost:3000' });
const pingEvent = client.event('ping');
pingEvent.subscribe((response) => pingEvent.send());

const server = new RXSocketServer();
const pingEvent = server.event('ping');
pingEvent.subscribe((response) => {
	console.log('Pong from ', response.socket);
});
setInterval(() => {
	console.log('Ping everyone');
	pingEvent.send();
}, 1000);
```

Send for result example:
```ts
const client = new RXSocketClient({ url: 'ws://localhost:3000' }));
const helloEvent = client.event('hello');
(async () => {
	let result = await helloEvent.sendForResult('Hello!');
	console.log(result.data); // 'Hi!'
	result = await result.replyForResult('How are you?');
	console.log(result.data);
})();

const server = new RXSocketServer();
const helloEvent = server.event('hello');
helloEvent.subscribe(async (message) => {
	console.log(message.data); // 'Hello!'
	let result = await message.replyForResult('Hi!');
	console.log(result.data); // 'How are you?'
	result.reply('I\'m good, thanks.');
});
```

Subscription example:
```ts
const client = new RXSocketClient({ url: 'ws://localhost:3000' });
const pingEvent = client.event('ping');
// pingEvent.subscribe();

const server = new RXSocketServer();
const pingEvent = server.event('ping');
setInterval(() => {
	pingEvent.send(); // will not send the event, because there is no subscribers
}, 1000);
```

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