UNPKG

5.64 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[![Build Status](https://travis-ci.org/ReactiveX/rxjs.svg?branch=master)](https://travis-ci.org/ReactiveX/rxjs)
6[![Coverage Status](https://coveralls.io/repos/github/ReactiveX/rxjs/badge.svg?branch=master)](https://coveralls.io/github/ReactiveX/rxjs?branch=master)
7[![npm version](https://badge.fury.io/js/%40reactivex%2Frxjs.svg)](http://badge.fury.io/js/%40reactivex%2Frxjs)
8[![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)
9
10[![Selenium Test Status](https://saucelabs.com/browser-matrix/rxjs5.svg)](https://saucelabs.com/u/rxjs5)
11
12# RxJS 6 Stable
13
14### MIGRATION AND RELEASE INFORMATION:
15
16Find out how to update to v6, **automatically update your TypeScript code**, and more!
17
18- [Current home is MIGRATION.md](./docs_app/content/guide/v6/migration.md)
19
20### FOR V 5.X PLEASE GO TO [THE 5.0 BRANCH](https://github.com/ReactiveX/rxjs/tree/5.x)
21
22Reactive 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.
23
24[Apache 2.0 License](LICENSE.txt)
25
26- [Code of Conduct](CODE_OF_CONDUCT.md)
27- [Contribution Guidelines](CONTRIBUTING.md)
28- [Maintainer Guidelines](doc/maintainer-guidelines.md)
29- [Creating Operators](doc/operator-creation.md)
30- [API Documentation (WIP)](https://rxjs.dev/)
31
32## Versions In This Repository
33
34- [master](https://github.com/ReactiveX/rxjs/commits/master) - This is all of the current, unreleased work, which is against v6 of RxJS right now
35- [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`
36
37## Important
38
39By 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.
40
41## Installation and Usage
42
43### ES6 via npm
44
45```sh
46npm install rxjs
47```
48
49It'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'`.
50
51```js
52import { range } from 'rxjs';
53import { map, filter } from 'rxjs/operators';
54
55range(1, 200).pipe(
56 filter(x => x % 2 === 1),
57 map(x => x + x)
58).subscribe(x => console.log(x));
59```
60
61Here, 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.
62
63### CommonJS via npm
64
65To install this library for CommonJS (CJS) usage, use the following command:
66
67```sh
68npm install rxjs
69```
70
71(Note: destructuring available in Node 8+)
72
73```js
74const { range } = require('rxjs');
75const { map, filter } = require('rxjs/operators');
76
77range(1, 200).pipe(
78 filter(x => x % 2 === 1),
79 map(x => x + x)
80).subscribe(x => console.log(x));
81```
82
83### CDN
84
85For CDN, you can use [unpkg](https://unpkg.com/):
86
87https://unpkg.com/rxjs/bundles/rxjs.umd.min.js
88
89The global namespace for rxjs is `rxjs`:
90
91```js
92const { range } = rxjs;
93const { map, filter } = rxjs.operators;
94
95range(1, 200).pipe(
96 filter(x => x % 2 === 1),
97 map(x => x + x)
98).subscribe(x => console.log(x));
99```
100
101## Goals
102
103- Smaller overall bundles sizes
104- Provide better performance than preceding versions of RxJS
105- To model/follow the [Observable Spec Proposal](https://github.com/zenparsing/es-observable) to the observable
106- Provide more modular file structure in a variety of formats
107- Provide more debuggable call stacks than preceding versions of RxJS
108
109## Building/Testing
110
111- `npm run build_all` - builds everything
112- `npm test` - runs tests
113- `npm run test_no_cache` - run test with `ts-node` set to false
114
115## Performance Tests
116
117Run `npm run build_perf` or `npm run perf` to run the performance tests with `protractor`.
118
119Run `npm run perf_micro [operator]` to run micro performance test benchmarking operator.
120
121## Adding documentation
122We 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).
123
124## Generating PNG marble diagrams
125
126The script `npm run tests2png` requires some native packages installed locally: `imagemagick`, `graphicsmagick`, and `ghostscript`.
127
128For Mac OS X with [Homebrew](http://brew.sh/):
129
130- `brew install imagemagick`
131- `brew install graphicsmagick`
132- `brew install ghostscript`
133- You may need to install the Ghostscript fonts manually:
134 - Download the tarball from the [gs-fonts project](https://sourceforge.net/projects/gs-fonts)
135 - `mkdir -p /usr/local/share/ghostscript && tar zxvf /path/to/ghostscript-fonts.tar.gz -C /usr/local/share/ghostscript`
136
137For Debian Linux:
138
139- `sudo add-apt-repository ppa:dhor/myway`
140- `apt-get install imagemagick`
141- `apt-get install graphicsmagick`
142- `apt-get install ghostscript`
143
144For Windows and other Operating Systems, check the download instructions here:
145
146- http://imagemagick.org
147- http://www.graphicsmagick.org
148- http://www.ghostscript.com/