995a16c4d1201f88ca7abe297b442075d84c2670d888ec788ef2f44485f0189c4e501c2fac86e37f99dc15ea07c9a41aae8a3a2c8704cd0f586e63cb963c38 5.2 KB

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