From f51b8f9391ca6d751517a72fdabb05ad8c1013d8 Mon Sep 17 00:00:00 2001 From: David Livingston Date: Mon, 21 Nov 2016 23:19:30 -0600 Subject: [PATCH] docs(README): add missing import in example (#2148) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- README.md | 6 ++++-- doc/installation.md | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 32a34125f6..0b17639c94 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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. diff --git a/doc/installation.md b/doc/installation.md index 461ba6afec..fd6b70d05f 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -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 @@ -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 @@ -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.