UNPKG

5.39 kBMarkdownView Raw
1<img src="doc/asset/Rx_Logo_S.png" alt="RxJS Logo" width="86" height="86"> RxJS: Reactive Extensions For JavaScript
2======================================
3
4
5[![CircleCI](https://circleci.com/gh/ReactiveX/rxjs/tree/6.x.svg?style=svg)](https://circleci.com/gh/ReactiveX/rxjs/tree/6.x)
6[![npm version](https://badge.fury.io/js/%40reactivex%2Frxjs.svg)](http://badge.fury.io/js/%40reactivex%2Frxjs)
7[![Join the chat at https://gitter.im/Reactive-Extensions/RxJS](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Reactive-Extensions/RxJS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
9# RxJS 6 Stable
10
11### MIGRATION AND RELEASE INFORMATION:
12
13Find out how to update to v6, **automatically update your TypeScript code**, and more!
14
15- [Current home is MIGRATION.md](./docs_app/content/guide/v6/migration.md)
16
17### FOR V 5.X PLEASE GO TO [THE 5.0 BRANCH](https://github.com/ReactiveX/rxjs/tree/5.x)
18
19Reactive Extensions Library for JavaScript. This is a rewrite of [Reactive-Extensions/RxJS](https://github.com/Reactive-Extensions/RxJS) and is the latest production-ready version of RxJS. This rewrite is meant to have better performance, better modularity, better debuggable call stacks, while staying mostly backwards compatible, with some breaking changes that reduce the API surface.
20
21[Apache 2.0 License](LICENSE.txt)
22
23- [Code of Conduct](CODE_OF_CONDUCT.md)
24- [Contribution Guidelines](CONTRIBUTING.md)
25- [Maintainer Guidelines](doc/maintainer-guidelines.md)
26- [Creating Operators](doc/operator-creation.md)
27- [API Documentation (WIP)](https://rxjs.dev/)
28
29## Versions In This Repository
30
31- [master](https://github.com/ReactiveX/rxjs/commits/master) - This is all of the current, unreleased work, which is against v6 of RxJS right now
32- [stable](https://github.com/ReactiveX/rxjs/commits/stable) - This is the branch for the latest version you'd get if you do `npm install rxjs`
33
34## Important
35
36By contributing or commenting on issues in this repository, whether you've read them or not, you're agreeing to the [Contributor Code of Conduct](CODE_OF_CONDUCT.md). Much like traffic laws, ignorance doesn't grant you immunity.
37
38## Installation and Usage
39
40### ES6 via npm
41
42```sh
43npm install rxjs
44```
45
46It's recommended to pull in the Observable creation methods you need directly from `'rxjs'` as shown below with `range`. And you can pull in any operator you need from one spot, under `'rxjs/operators'`.
47
48```js
49import { range } from 'rxjs';
50import { map, filter } from 'rxjs/operators';
51
52range(1, 200).pipe(
53 filter(x => x % 2 === 1),
54 map(x => x + x)
55).subscribe(x => console.log(x));
56```
57
58Here, we're using the built-in `pipe` method on Observables to combine operators. See [pipeable operators](https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md) for more information.
59
60### CommonJS via npm
61
62To install this library for CommonJS (CJS) usage, use the following command:
63
64```sh
65npm install rxjs
66```
67
68(Note: destructuring available in Node 8+)
69
70```js
71const { range } = require('rxjs');
72const { map, filter } = require('rxjs/operators');
73
74range(1, 200).pipe(
75 filter(x => x % 2 === 1),
76 map(x => x + x)
77).subscribe(x => console.log(x));
78```
79
80### CDN
81
82For CDN, you can use [unpkg](https://unpkg.com/):
83
84https://unpkg.com/rxjs/bundles/rxjs.umd.min.js
85
86The global namespace for rxjs is `rxjs`:
87
88```js
89const { range } = rxjs;
90const { map, filter } = rxjs.operators;
91
92range(1, 200).pipe(
93 filter(x => x % 2 === 1),
94 map(x => x + x)
95).subscribe(x => console.log(x));
96```
97
98## Goals
99
100- Smaller overall bundles sizes
101- Provide better performance than preceding versions of RxJS
102- To model/follow the [Observable Spec Proposal](https://github.com/zenparsing/es-observable) to the observable
103- Provide more modular file structure in a variety of formats
104- Provide more debuggable call stacks than preceding versions of RxJS
105
106## Building/Testing
107
108- `npm run build_all` - builds everything
109- `npm test` - runs tests
110- `npm run test_no_cache` - run test with `ts-node` set to false
111
112## Performance Tests
113
114Run `npm run build_perf` or `npm run perf` to run the performance tests with `protractor`.
115
116Run `npm run perf_micro [operator]` to run micro performance test benchmarking operator.
117
118## Adding documentation
119We appreciate all contributions to the documentation of any type. All of the information needed to get the docs app up and running locally as well as how to contribute can be found in the [documentation directory](./docs_app).
120
121## Generating PNG marble diagrams
122
123The script `npm run tests2png` requires some native packages installed locally: `imagemagick`, `graphicsmagick`, and `ghostscript`.
124
125For Mac OS X with [Homebrew](http://brew.sh/):
126
127- `brew install imagemagick`
128- `brew install graphicsmagick`
129- `brew install ghostscript`
130- You may need to install the Ghostscript fonts manually:
131 - Download the tarball from the [gs-fonts project](https://sourceforge.net/projects/gs-fonts)
132 - `mkdir -p /usr/local/share/ghostscript && tar zxvf /path/to/ghostscript-fonts.tar.gz -C /usr/local/share/ghostscript`
133
134For Debian Linux:
135
136- `sudo add-apt-repository ppa:dhor/myway`
137- `apt-get install imagemagick`
138- `apt-get install graphicsmagick`
139- `apt-get install ghostscript`
140
141For Windows and other Operating Systems, check the download instructions here:
142
143- http://imagemagick.org
144- http://www.graphicsmagick.org
145- http://www.ghostscript.com/