UNPKG

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