Skip to content

Commit

Permalink
Update observer.md (#6387)
Browse files Browse the repository at this point in the history
* Update observer.md

migrate to 7.

* Update observer.md

* docs: docs_app/content/guide/observer.md

* docs: docs_app/content/guide/observer.md

Co-authored-by: Nicholas Jamieson <nicholas@cartant.com>
  • Loading branch information
xp44mm and cartant committed May 8, 2021
1 parent d86da14 commit c23e567
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions docs_app/content/guide/observer.md
Expand Up @@ -20,7 +20,7 @@ observable.subscribe(observer);

Observers in RxJS may also be *partial*. If you don't provide one of the callbacks, the execution of the Observable will still happen normally, except some types of notifications will be ignored, because they don't have a corresponding callback in the Observer.

The example below is an Observer without the `complete` callback:
The example below is an `Observer` without the `complete` callback:

```ts
const observer = {
Expand All @@ -29,18 +29,10 @@ const observer = {
};
```

When subscribing to an Observable, you may also just provide the callbacks as arguments, without being attached to an Observer object, for instance like this:
When subscribing to an `Observable`, you may also just provide the next callback as an argument, without being attached to an `Observer` object, for instance like this:

```ts
observable.subscribe(x => console.log('Observer got a next value: ' + x));
```

Internally in `observable.subscribe`, it will create an Observer object using the first callback argument as the `next` handler. All three types of callbacks may be provided as arguments:

```ts
observable.subscribe(
x => console.log('Observer got a next value: ' + x),
err => console.error('Observer got an error: ' + err),
() => console.log('Observer got a complete notification')
);
```
Internally in `observable.subscribe`, it will create an `Observer` object using the callback argument as the `next` handler.

0 comments on commit c23e567

Please sign in to comment.