docs: update rxjs refs (#31780)

PR Close #31780
This commit is contained in:
Judy Bogart 2019-07-22 09:03:38 -07:00 committed by Alex Rickabaugh
parent f8c27d42ed
commit 2913340af7
3 changed files with 14 additions and 7 deletions

View File

@ -2,13 +2,15 @@
Angular makes use of observables as an interface to handle a variety of common asynchronous operations. For example: Angular makes use of observables as an interface to handle a variety of common asynchronous operations. For example:
* The `EventEmitter` class extends `Observable`. * The `EventEmitter` class lets you use observables with the Angular `@Output` decorator.
* The HTTP module uses observables to handle AJAX requests and responses. * The HTTP module uses observables to handle AJAX requests and responses.
* The Router and Forms modules use observables to listen for and respond to user-input events. * The Router and Forms modules use observables to listen for and respond to user-input events.
## Event emitter ## Event emitter
Angular provides an `EventEmitter` class that is used when publishing values from a component through the `@Output()` decorator. `EventEmitter` extends `Observable`, adding an `emit()` method so it can send arbitrary values. When you call `emit()`, it passes the emitted value to the `next()` method of any subscribed observer. Angular provides an `EventEmitter` class that is used when publishing values from a component through the `@Output()` decorator.
`EventEmitter` extends [RxJS `Subject`](https://rxjs.dev/api/index/class/Subject), adding an `emit()` method so it can send arbitrary values.
When you call `emit()`, it passes the emitted value to the `next()` method of any subscribed observer.
A good example of usage can be found on the [EventEmitter](https://angular.io/api/core/EventEmitter) documentation. Here is the example component that listens for open and close events: A good example of usage can be found on the [EventEmitter](https://angular.io/api/core/EventEmitter) documentation. Here is the example component that listens for open and close events:

View File

@ -1,6 +1,6 @@
# The RxJS library # The RxJS library
Reactive programming is an asynchronous programming paradigm concerned with data streams and the propagation of change ([Wikipedia](https://en.wikipedia.org/wiki/Reactive_programming)). RxJS (Reactive Extensions for JavaScript) is a library for reactive programming using observables that makes it easier to compose asynchronous or callback-based code ([RxJS Docs](http://reactivex.io/rxjs/)). Reactive programming is an asynchronous programming paradigm concerned with data streams and the propagation of change ([Wikipedia](https://en.wikipedia.org/wiki/Reactive_programming)). RxJS (Reactive Extensions for JavaScript) is a library for reactive programming using observables that makes it easier to compose asynchronous or callback-based code. See ([RxJS Docs](https://rxjs.dev/guide/overview)).
RxJS provides an implementation of the `Observable` type, which is needed until the type becomes part of the language and until browsers support it. The library also provides utility functions for creating and working with observables. These utility functions can be used for: RxJS provides an implementation of the `Observable` type, which is needed until the type becomes part of the language and until browsers support it. The library also provides utility functions for creating and working with observables. These utility functions can be used for:
@ -45,7 +45,7 @@ The `pipe()` function is also a method on the RxJS `Observable`, so you use this
### Common operators ### Common operators
RxJS provides many operators, but only a handful are used frequently. For a list of operators and usage samples, visit the [RxJS API Documentation](https://rxjs-dev.firebaseapp.com/api). RxJS provides many operators, but only a handful are used frequently. For a list of operators and usage samples, visit the [RxJS API Documentation](https://rxjs.dev/api).
<div class="alert is-helpful"> <div class="alert is-helpful">
Note that, for Angular apps, we prefer combining operators with pipes, rather than chaining. Chaining is used in many RxJS examples. Note that, for Angular apps, we prefer combining operators with pipes, rather than chaining. Chaining is used in many RxJS examples.

View File

@ -11,12 +11,16 @@
import {Subject, Subscription} from 'rxjs'; import {Subject, Subscription} from 'rxjs';
/** /**
* Use in directives and components to emit custom events synchronously * Use in components with the `@Output` directive to emit custom events
* or asynchronously, and register handlers for those events by subscribing * synchronously or asynchronously, and register handlers for those events
* to an instance. * by subscribing to an instance.
* *
* @usageNotes * @usageNotes
* *
* Extends
* [RxJS `Subject`](https://rxjs.dev/api/index/class/Subject)
* for Angular by adding the `emit()` method.
*
* In the following example, a component defines two output properties * In the following example, a component defines two output properties
* that create event emitters. When the title is clicked, the emitter * that create event emitters. When the title is clicked, the emitter
* emits an open or close event to toggle the current visibility state. * emits an open or close event to toggle the current visibility state.
@ -54,6 +58,7 @@ import {Subject, Subscription} from 'rxjs';
* <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy> * <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
* ``` * ```
* *
* @see [Observables: Event emitter](guide/observables-in-angular#event-emitter)
* @publicApi * @publicApi
*/ */
export class EventEmitter<T extends any> extends Subject<T> { export class EventEmitter<T extends any> extends Subject<T> {