Skip to content

Commit

Permalink
docs(README): add missing import in example (#2148)
Browse files Browse the repository at this point in the history
Add a missing import statement for Observable.of. Without this fix, the
example code would generate an error message like
'Uncaught TypeError: _Observable.Observable.of is not a function(…)'
at runtime.
  • Loading branch information
dliv authored and jayphelps committed Nov 22, 2016
1 parent e036e79 commit f51b8f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ To import only what you need by patching (this is useful for size-sensitive bund

```js
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/map';

Observable.of(1,2,3).map(x => x + '!!!'); // etc
Expand Down Expand Up @@ -78,6 +79,7 @@ Import only what you need and patch Observable (this is useful in size-sensitive
```js
var Observable = require('rxjs/Observable').Observable;
// patch Observable with appropriate methods
require('rxjs/add/observable/of');
require('rxjs/add/operator/map');

Observable.of(1,2,3).map(function (x) { return x + '!!!'; }); // etc
Expand All @@ -86,10 +88,10 @@ Observable.of(1,2,3).map(function (x) { return x + '!!!'; }); // etc
Import operators and use them _manually_ you can do the following (this is also useful for bundling):

```js
var Observable = require('rxjs/Observable').Observable;
var of = require('rxjs/observable/of').of;
var map = require('rxjs/operator/map').map;

map.call(Observable.of(1,2,3), function (x) { return x + '!!!'; });
map.call(of(1,2,3), function (x) { return x + '!!!'; });
```

You can also use the above method to build your own Observable and export it from your own module.
Expand Down
10 changes: 6 additions & 4 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ Rx.Observable.of(1,2,3)

To import only what you need by patching (this is useful for size-sensitive bundling):

```js
import {Observable} from 'rxjs/Observable';
```js
import { Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/map';

Observable.of(1,2,3).map(x => x + '!!!'); // etc
Expand Down Expand Up @@ -52,6 +53,7 @@ Import only what you need and patch Observable (this is useful in size-sensitive
```js
var Observable = require('rxjs/Observable').Observable;
// patch Observable with appropriate methods
require('rxjs/add/observable/of');
require('rxjs/add/operator/map');

Observable.of(1,2,3).map(function (x) { return x + '!!!'; }); // etc
Expand All @@ -60,10 +62,10 @@ Observable.of(1,2,3).map(function (x) { return x + '!!!'; }); // etc
Import operators and use them _manually_ you can do the following (this is also useful for bundling):

```js
var Observable = require('rxjs/Observable').Observable;
var of = require('rxjs/observable/of').of;
var map = require('rxjs/operator/map').map;

map.call(Observable.of(1,2,3), function (x) { return x + '!!!'; });
map.call(of(1,2,3), function (x) { return x + '!!!'; });
```

You can also use the above method to build your own Observable and export it from your own module.
Expand Down

0 comments on commit f51b8f9

Please sign in to comment.