Skip to content

Commit f51b8f9

Browse files
dlivjayphelps
authored andcommitted
docs(README): add missing import in example (#2148)
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.
1 parent e036e79 commit f51b8f9

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ To import only what you need by patching (this is useful for size-sensitive bund
4242

4343
```js
4444
import { Observable } from 'rxjs/Observable';
45+
import 'rxjs/add/observable/of';
4546
import 'rxjs/add/operator/map';
4647

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

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

8890
```js
89-
var Observable = require('rxjs/Observable').Observable;
91+
var of = require('rxjs/observable/of').of;
9092
var map = require('rxjs/operator/map').map;
9193

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

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

doc/installation.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ Rx.Observable.of(1,2,3)
1414

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

17-
```js
18-
import {Observable} from 'rxjs/Observable';
17+
```js
18+
import { Observable} from 'rxjs/Observable';
19+
import 'rxjs/add/observable/of';
1920
import 'rxjs/add/operator/map';
2021

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

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

6264
```js
63-
var Observable = require('rxjs/Observable').Observable;
65+
var of = require('rxjs/observable/of').of;
6466
var map = require('rxjs/operator/map').map;
6567

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

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

0 commit comments

Comments
 (0)