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