# rxjs-addons

> Rx add-ons

Latest version **0.0.4** (published 2019-01-09) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2019-01-09 |
| First published | 2018-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Stanislaw Glogowski |
| Maintainers | staszek |

## Links

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

## Dependencies (2)

- [rxjs](https://npm.io/package/rxjs.md) ^6.3.3
- [deep-equal-extended](https://npm.io/package/deep-equal-extended.md) 0.0.2

## Recent versions

- 0.0.4 (latest) — 2019-01-09
- 0.0.3 — 2018-09-26
- 0.0.2 — 2018-09-19
- 0.0.1 — 2018-09-17

## README

# Rx add-ons

[![NPM version][npm-image]][npm-url]

## Installation

```bash
$ npm i rxjs-addons -S
```

## Example usage

### `AttributesProxySubject`

```js
import { AttributesProxySubject } from "rxjs-addons";
const subject = new AttributesProxySubject({
  a: 1,
  b: 2,
}, {
  schema: {
    a: {
      getter: true,
      setter: true
    },
    b: {
      subject,
    },
  },
});

console.log(subject.a) // 1
console.log(subject.b) // undefined

subject.b$.subscribe((value) => console.log("b:", value));

/*
  b: 2
 */

```

### `ErrorSubject`

```js
import { ErrorSubject } from "rxjs-addons";
const subject = new ErrorSubject();

subject.subscribe((err) => console.error(err));

// regular catch
try {
  throw new Error("Error");
} catch (err) {
  subject.error(err); // or errorSubject.next(err); 
}

// wrapping promise or async function 
subject.wrapAsync(async () => {
  throw new Error("Error");
});
subject.wrapAsync(Promise.reject(new Error("Error")));

// wrapping promise or async function and return promise
subject
  .wrapTAsync<string>(async () => {
    ... // 
    return "value";
  })
  .then((value) => console.log(value));
```

### `UniqueBehaviorSubject`

```js
import { UniqueBehaviorSubject } from "rxjs-addons";
const subject = new UniqueBehaviorSubject(1); // with default value

console.log(subject.value); // 1

subject.next(2);
subject.next(2);
subject.next(2);
subject.next(3);
subject.next(3);

subject.subscribe((value) => console.log("value:", value));

/*
  value: 1
  value: 2
  value: 3
 */

```

## Testing

```bash
$ npm test
```

## License

The MIT License

[npm-image]: https://badge.fury.io/js/rxjs-addons.svg
[npm-url]: http://npmjs.com/package/rxjs-addons

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