# rxjs-observable-collections

> Implementations of ES2015 collections (Array, Set, Map, WeakSet, WeakMap) which emit an rxjs observable stream of changes

Latest version **1.0.1** (published 2019-01-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install rxjs-observable-collections
pnpm add rxjs-observable-collections
yarn add rxjs-observable-collections
bun add rxjs-observable-collections
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-01-04 |
| First published | 2018-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 151.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Craig Fowler |
| Maintainers | craigfowler |
| Keywords | rxjs, array, map, set, weakmap, weakset, observable, mutate, change, events |

## Links

- npm: https://www.npmjs.com/package/rxjs-observable-collections
- Repository: https://github.com/csf-dev/rxjs-observable-collections
- Homepage: https://github.com/csf-dev/rxjs-observable-collections#readme
- Issues: https://github.com/csf-dev/rxjs-observable-collections/issues
- npm.io page: https://npm.io/package/rxjs-observable-collections

## Dependencies (2)

- [core-js](https://npm.io/package/core-js.md) ^2.6.1
- [@babel/polyfill](https://npm.io/package/@babel/polyfill.md) ^7.0.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-01-04
- 1.0.0 — 2018-12-11
- 0.2.1 — 2018-12-10
- 0.2.0 — 2018-12-09
- 0.1.0 — 2018-12-04

## README

The **[Observable Collections](https://www.npmjs.com/package/rxjs-observable-collections)** module provides implementations of JavaScript/ECMAScript 'collection' objects which emit [an rxjs observable action stream] as they are mutated: Array, Set, Map, WeakSet & WeakMap.  Reactive applications which use **rxjs** may subscribe/observe these actions to synchronise logic with modifications to those collections.

Here is *an annotated minimal example* showing the usage of an [observable Array]. You may notice that it uses ECMAScript 2015 syntax.  This module is usable in any environment which [supports ECMAScript 5+]; in practice that's Internet Explorer 9+ and *all other modern browsers*.


```js
const myArray = new ObservableArray();

// Immediately, the initial (empty) state
// of the array will be logged
const subscription = myArray.actions
    .subscribe(action => console.log(action));

// As the item is pushed, a 'push' action
// will also be logged
myArray.push('An item');

// Tidy up after ourselves
subscription.unsubscribe();
```

[**Full documentation** is available] on this repository's wiki.

[an rxjs observable action stream]: https://rxjs-dev.firebaseapp.com/
[observable Array]: https://github.com/csf-dev/rxjs-observable-collections/wiki/ObservableArray
[observable arrays]: https://github.com/csf-dev/rxjs-observable-collections/wiki/ObservableArray
[supports ECMAScript 5+]: https://github.com/csf-dev/rxjs-observable-collections/wiki#browserenvironment-support
[**Full documentation** is available]: https://github.com/csf-dev/rxjs-observable-collections/wiki

## Limitations
In order to provide [the range of browser & environment support], this module has to accept *two limitations, applicable to [observable arrays]*.  Specifically, no observable actions are emitted when either:

* Using *brackets notation* to set array items by index
* The array is *resized* via its `length` property

[These limitations are covered at length], with information how they may be rectified someday.  At present the solution is deemed to be too 'costly' in terms of browser support.  For example, it would exclude *all* versions of Internet Explorer.

[the range of browser & environment support]: https://github.com/csf-dev/rxjs-observable-collections/wiki#browserenvironment-support
[These limitations are covered at length]: https://github.com/csf-dev/rxjs-observable-collections/issues/4

### Workaround
As a workaround to these limitations, two additional functions are available for observable arrays.

```js
// Sets an item by index
myArray.setItem(3, 'replacement item');

// Resizes the array
myArray.resize(20);
```

These functions have the same functionality as the two scenarios described above but also emit the observable action as expected.

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