项目原始demo,不改动
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
Este repositorio está archivado. Puede ver los archivos y clonarlo, pero no puede subir cambios o reportar incidencias ni pedir Pull Requests.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. [![Build Status](https://travis-ci.org/ReactiveX/rxjs.svg?branch=master)](https://travis-ci.org/ReactiveX/rxjs)
  2. [![Coverage Status](https://coveralls.io/repos/github/ReactiveX/rxjs/badge.svg?branch=master)](https://coveralls.io/github/ReactiveX/rxjs?branch=master)
  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. [![Selenium Test Status](https://saucelabs.com/browser-matrix/rxjs5.svg)](https://saucelabs.com/u/rxjs5)
  6. # RxJS 5
  7. 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.
  8. [Apache 2.0 License](LICENSE.txt)
  9. - [Code of Conduct](CODE_OF_CONDUCT.md)
  10. - [Contribution Guidelines](CONTRIBUTING.md)
  11. - [Maintainer Guidelines](doc/maintainer-guidelines.md)
  12. - [Creating Operators](doc/operator-creation.md)
  13. - [Migrating From RxJS 4 to RxJS 5](MIGRATION.md)
  14. - [API Documentation (WIP)](http://reactivex.io/rxjs)
  15. ## Versions In This Repository
  16. - [master](https://github.com/ReactiveX/rxjs/commits/master) - commits that will be included in the next _minor_ or _patch_ release
  17. - [next](https://github.com/ReactiveX/rxjs/commits/next) - commits that will be included in the next _major_ release (breaking changes)
  18. Most PRs should be made to **master**, unless you know it is a breaking change.
  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. To import the entire core set of functionality:
  27. ```js
  28. import Rx from 'rxjs/Rx';
  29. Rx.Observable.of(1,2,3)
  30. ```
  31. To import only what you need by patching (this is useful for size-sensitive bundling):
  32. ```js
  33. import { Observable } from 'rxjs/Observable';
  34. import 'rxjs/add/observable/of';
  35. import 'rxjs/add/operator/map';
  36. Observable.of(1,2,3).map(x => x + '!!!'); // etc
  37. ```
  38. To import what you need and use it with proposed [bind operator](https://github.com/tc39/proposal-bind-operator):
  39. > Note: This additional syntax requires [transpiler support](http://babeljs.io/docs/plugins/transform-function-bind/) and this syntax may be completely withdrawn from TC39 without notice! Use at your own risk.
  40. ```js
  41. import { Observable } from 'rxjs/Observable';
  42. import { of } from 'rxjs/observable/of';
  43. import { map } from 'rxjs/operator/map';
  44. Observable::of(1,2,3)::map(x => x + '!!!'); // etc
  45. ```
  46. ### CommonJS via npm
  47. To install this library for CommonJS (CJS) usage, use the following command:
  48. ```sh
  49. npm install rxjs
  50. ```
  51. Import all core functionality:
  52. ```js
  53. var Rx = require('rxjs/Rx');
  54. Rx.Observable.of(1,2,3); // etc
  55. ```
  56. Import only what you need and patch Observable (this is useful in size-sensitive bundling scenarios):
  57. ```js
  58. var Observable = require('rxjs/Observable').Observable;
  59. // patch Observable with appropriate methods
  60. require('rxjs/add/observable/of');
  61. require('rxjs/add/operator/map');
  62. Observable.of(1,2,3).map(function (x) { return x + '!!!'; }); // etc
  63. ```
  64. Import operators and use them _manually_ you can do the following (this is also useful for bundling):
  65. ```js
  66. var of = require('rxjs/observable/of').of;
  67. var map = require('rxjs/operator/map').map;
  68. map.call(of(1,2,3), function (x) { return x + '!!!'; });
  69. ```
  70. You can also use the above method to build your own Observable and export it from your own module.
  71. ### All Module Types (CJS/ES6/AMD/TypeScript) via npm
  72. To install this library via [npm](https://www.npmjs.org) **version 3**, use the following command:
  73. ```sh
  74. npm install @reactivex/rxjs
  75. ```
  76. This will include CJS/Global builds and can be used for all module types.
  77. If you are using npm **version 2** before this library has achieved a stable version, you need to specify the library version explicitly:
  78. ```sh
  79. npm install @reactivex/rxjs@5.0.0
  80. ```
  81. ### CDN
  82. For CDN, you can use [unpkg](https://unpkg.com/):
  83. https://unpkg.com/rxjs@version/bundles/Rx.min.js
  84. *replace **version** with the current version. See [docs](http://reactivex.io/rxjs/manual/installation.html#cdn).*
  85. #### Node.js Usage:
  86. ```js
  87. var Rx = require('@reactivex/rxjs');
  88. Rx.Observable.of('hello world')
  89. .subscribe(function(x) { console.log(x); });
  90. ```
  91. ## Goals
  92. - Provide better performance than preceding versions of RxJS
  93. - To model/follow the [Observable Spec Proposal](https://github.com/zenparsing/es-observable) to the observable.
  94. - Provide more modular file structure in a variety of formats
  95. - Provide more debuggable call stacks than preceding versions of RxJS
  96. ## Building/Testing
  97. The build and test structure is fairly primitive at the moment. There are various npm scripts that can be run:
  98. - build_es6: Transpiles the TypeScript files from `src/` to `dist/es6`
  99. - build_cjs: Transpiles the ES6 files from `dist/es6` to `dist/cjs`
  100. - build_amd: Transpiles the ES6 files from `dist/es6` to `dist/amd`
  101. - build_global: Transpiles/Bundles the CommonJS files from `dist/cjs` to `dist/global/Rx.js`
  102. - build_all: Performs all of the above in the proper order.
  103. - build_test: builds ES6, then CommonJS, then runs the tests with `jasmine`
  104. - build_perf: builds ES6, CommonJS, then global, then runs the performance tests with `protractor`
  105. - build_docs: generates API documentation from `dist/es6` to `dist/docs`
  106. - build_cover: runs `istanbul` code coverage against test cases
  107. - test: runs tests with `jasmine`, must have built prior to running.
  108. - tests2png: generates PNG marble diagrams from test cases.
  109. `npm run info` will list available script.
  110. ### Example
  111. ```sh
  112. # build all the things!
  113. npm run build_all
  114. ```
  115. ## Performance Tests
  116. Run `npm run build_perf` or `npm run perf` to run the performance tests with `protractor`.
  117. Run `npm run perf_micro` to run micro performance test benchmarking operator.
  118. ## Adding documentation
  119. RxNext uses [ESDoc](https://esdoc.org/) to generate API documentation. Refer to ESDoc's documentation for syntax. Run `npm run build_docs` to generate.
  120. ## Generating PNG marble diagrams
  121. The script `npm run tests2png` requires some native packages installed locally: `imagemagick`, `graphicsmagick`, and `ghostscript`.
  122. For Mac OS X with [Homebrew](http://brew.sh/):
  123. - `brew install imagemagick`
  124. - `brew install graphicsmagick`
  125. - `brew install ghostscript`
  126. - You may need to install the Ghostscript fonts manually:
  127. - Download the tarball from the [gs-fonts project](https://sourceforge.net/projects/gs-fonts)
  128. - `mkdir -p /usr/local/share/ghostscript && tar zxvf /path/to/ghostscript-fonts.tar.gz -C /usr/local/share/ghostscript`
  129. For Debian Linux:
  130. - `sudo add-apt-repository ppa:dhor/myway`
  131. - `apt-get install imagemagick`
  132. - `apt-get install graphicsmagick`
  133. - `apt-get install ghostscript`
  134. For Windows and other Operating Systems, check the download instructions here:
  135. - http://imagemagick.org
  136. - http://www.graphicsmagick.org
  137. - http://www.ghostscript.com/