Debian Codegraph @

any-observable/readme.md

raw
1 # any-observable [![Build Status](https://travis-ci.org/sindresorhus/any-observable.svg?branch=master)](https://travis-ci.org/sindresorhus/any-observable)
2
3 > Support any [Observable](https://github.com/zenparsing/es-observable) library and polyfill
4
5 Like [`any-promise`](https://github.com/kevinbeaty/any-promise). *(Docs are lacking here, so refer to those docs for now)*
6
7
8 ## Install
9
10 ```
11 $ npm install any-observable
12 ```
13
14 You must also install the Observable library you want:
15
16 ```
17 $ npm install zen-observable
18 ```
19
20
21 ## Usage
22
23 ```js
24 const Observable = require('any-observable'); // Using `zen-observable` since it's installed
25
26 Observable.of(1, 2).forEach(value => {
27 console.log(value);
28 });
29 //=> 1
30 //=> 2
31 ```
32
33 ## Registration Shortcuts
34
35 This adds the following shortcut registrations:
36
37 - `rxjs-min`: Bare bones [RxJs](https://github.com/ReactiveX/rxjs) Observable implementation. See the [RxJs Installation Instructions](http://reactivex.io/rxjs/manual/installation.html) for details on patching additional methods into that implementation.
38 - `rxjs`: Same as `rxjs-min`, but adds the somewhat standard `Observable.of` and `Observable.from`.
39 - `rxjs-all`: The kitchen sink approach to Observables.
40 - `zen`: The [`zen-observable`](https://github.com/zenparsing/zen-observable) implementation.
41
42 Shortcut registration can be done as follows:
43
44 ```js
45 import 'any-observable/register/zen';
46 ```
47
48 It's especially handy for more recent versions of Node.js (and many test runners), that offer a `--require` flag:
49
50 ```
51 $ ava --require=any-observable/register/zen test.js
52 ```
53
54
55 ## Related
56
57 - [is-observable](https://github.com/sindresorhus/is-observable) - Check if a value is an Observable
58 - [observable-to-promise](https://github.com/sindresorhus/observable-to-promise) - Convert an Observable to a Promise