UNPKG

5.99 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/stable)
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)](http://reactivex.io/rxjs)
31
32## Versions In This Repository
33
34- [master](https://github.com/ReactiveX/rxjs/commits/master) - This 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
49To import only what you need by patching (this is useful for size-sensitive bundling):
50
51```js
52import { Observable, Subject, ReplaySubject, from, of, range } from 'rxjs';
53import { map, filter, switchMap } from 'rxjs/operators';
54
55range(1, 200)
56 .pipe(filter(x => x % 2 === 1), map(x => x + x))
57 .subscribe(x => console.log(x));
58```
59
60Alternatively, you can use the built-in `pipe` method on Observables. See [pipeable operators](https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md) for more information.
61
62### CommonJS via npm
63
64To install this library for CommonJS (CJS) usage, use the following command:
65
66```sh
67npm install rxjs
68```
69
70(Note: destructuring available in Node 8+)
71
72```js
73const { Observable, Subject, ReplaySubject, from, of, range } = require('rxjs');
74const { map, filter, switchMap } = require('rxjs/operators');
75
76range(1, 200)
77 .pipe(filter(x => x % 2 === 1), map(x => x + x))
78 .subscribe(x => console.log(x));
79```
80
81### CDN
82
83For CDN, you can use [unpkg](https://unpkg.com/):
84
85https://unpkg.com/rxjs/bundles/rxjs.umd.min.js
86
87The global namespace for rxjs is `rxjs`:
88
89```js
90const { Observable, Subject, ReplaySubject, from, of, range } = rxjs;
91const { map, filter, switchMap } = rxjs.operators;
92
93range(1, 200)
94 .pipe(filter(x => x % 2 === 1), 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
111`npm run info` will list available scripts (there are a lot LOL)
112
113## Performance Tests
114
115Run `npm run build_perf` or `npm run perf` to run the performance tests with `protractor`.
116
117Run `npm run perf_micro [operator]` to run micro performance test benchmarking operator.
118
119## Adding documentation
120RxNext uses [ESDoc](https://esdoc.org/) to generate API documentation. Refer to ESDoc's documentation for syntax. Run `npm run build_docs` to generate.
121
122At the moment we are trying to improve the documentation. For this purpose the Documentation is in a separate [GitHub Repository](https://github.com/ReactiveX/rxjs-docs).
123For a quick instruction take a look at the [documentation guidelines](https://github.com/ReactiveX/rxjs-docs/blob/master/DOCUMENTATION_GUIDELINES.md).
124We are really happy about any type of contributions!
125
126## Generating PNG marble diagrams
127
128The script `npm run tests2png` requires some native packages installed locally: `imagemagick`, `graphicsmagick`, and `ghostscript`.
129
130For Mac OS X with [Homebrew](http://brew.sh/):
131
132- `brew install imagemagick`
133- `brew install graphicsmagick`
134- `brew install ghostscript`
135- You may need to install the Ghostscript fonts manually:
136 - Download the tarball from the [gs-fonts project](https://sourceforge.net/projects/gs-fonts)
137 - `mkdir -p /usr/local/share/ghostscript && tar zxvf /path/to/ghostscript-fonts.tar.gz -C /usr/local/share/ghostscript`
138
139For Debian Linux:
140
141- `sudo add-apt-repository ppa:dhor/myway`
142- `apt-get install imagemagick`
143- `apt-get install graphicsmagick`
144- `apt-get install ghostscript`
145
146For Windows and other Operating Systems, check the download instructions here:
147
148- http://imagemagick.org
149- http://www.graphicsmagick.org
150- http://www.ghostscript.com/