From b8887ddf16b996589f1135969675c0f3e0a5f769 Mon Sep 17 00:00:00 2001 From: Ro Savage Date: Wed, 28 Feb 2018 17:40:55 +1300 Subject: [PATCH] docs: fix table in comparing observables guide (#22485) PR Close #22485 --- aio/content/guide/comparing-observables.md | 86 +++++++++++----------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/aio/content/guide/comparing-observables.md b/aio/content/guide/comparing-observables.md index 743ae11658..ba6ab8171f 100644 --- a/aio/content/guide/comparing-observables.md +++ b/aio/content/guide/comparing-observables.md @@ -89,47 +89,51 @@ promise.then(() => { The following code snippets illustrate how the same kind of operation is defined using observables and promises. - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperationObservablePromise
Creation -
new Observable((observer) => {
-  observer.next(123);
-});
-
-
new Promise((resolve, reject) => {
-  resolve(123);
-});
-
Transform
obs.map((value) => value * 2 );
promise.then((value) => value * 2);
Subscribe -
sub = obs.subscribe((value) => {
-  console.log(value)
-});
-
-
promise.then((value) => {
-  console.log(value);
-});
-
Unsubscribe
sub.unsubscribe();
Implied by promise resolution.
OperationObservablePromise
Creation +
new Observable((observer) => {
+    observer.next(123);
+  });
+
+
new Promise((resolve, reject) => {
+    resolve(123);
+  });
+
Transform
obs.map((value) => value * 2 );
promise.then((value) => value * 2);
Subscribe +
sub = obs.subscribe((value) => {
+    console.log(value)
+  });
+
+
promise.then((value) => {
+    console.log(value);
+  });
+
Unsubscribe
sub.unsubscribe();
Implied by promise resolution.
## Observables compared to events API