Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions aio/content/guide/comparing-observables.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ promise.then((value) => {
* Observables differentiate between transformation function such as a map and subscription. Only subscription activates the subscriber function to start computing the values.


<code-example hideCopy>observable.map((v) => 2*v);</code-example>
<code-example hideCopy>observable.pipe(map((v) => 2*v));</code-example>


* Promises do not differentiate between the last `.then` clauses (equivalent to subscription) and intermediate `.then` clauses (equivalent to map).
Expand Down Expand Up @@ -112,7 +112,7 @@ The following code snippets illustrate how the same kind of operation is defined
</tr>
<tr>
<td>Transform</td>
<td><pre>obs.map((value) => value * 2 );</pre></td>
<td><pre>obs.pipe(map((value) => value * 2));</pre></td>
<td><pre>promise.then((value) => value * 2);</pre></td>
</tr>
<tr>
Expand Down Expand Up @@ -227,7 +227,7 @@ An observable produces values over time. An array is created as a static set of
<tr>
<td><pre>concat()</pre></td>
<td>
<pre>obs.concat(obsB)</pre>
<pre>concat(obs, obsB)</pre>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concat operator is deprecated. Currently, static concat creator function is only recommended.

<pre>➞1➞2➞3➞5➞7➞'a'➞'b'➞'c'</pre>
</td>
<td>
Expand All @@ -238,7 +238,7 @@ An observable produces values over time. An array is created as a static set of
<tr>
<td><pre>filter()</pre></td>
<td>
<pre>obs.filter((v) => v>3)</pre>
<pre>obs.pipe(filter((v) => v>3))</pre>
<pre>➞5➞7</pre>
</td>
<td>
Expand All @@ -249,7 +249,7 @@ An observable produces values over time. An array is created as a static set of
<tr>
<td><pre>find()</pre></td>
<td>
<pre>obs.find((v) => v>3)</pre>
<pre>obs.pipe(find((v) => v>3))</pre>
<pre>➞5</pre>
</td>
<td>
Expand All @@ -260,7 +260,7 @@ An observable produces values over time. An array is created as a static set of
<tr>
<td><pre>findIndex()</pre></td>
<td>
<pre>obs.findIndex((v) => v>3)</pre>
<pre>obs.pipe(findIndex((v) => v>3))</pre>
<pre>➞3</pre>
</td>
<td>
Expand All @@ -271,9 +271,9 @@ An observable produces values over time. An array is created as a static set of
<tr>
<td><pre>forEach()</pre></td>
<td>
<pre>obs.forEach((v) => {
<pre>obs.pipe(tap((v) => {
console.log(v);
})
}))
1
2
3
Expand All @@ -294,7 +294,7 @@ An observable produces values over time. An array is created as a static set of
<tr>
<td><pre>map()</pre></td>
<td>
<pre>obs.map((v) => -v)</pre>
<pre>obs.pipe(map((v) => -v))</pre>
<pre>➞-1➞-2➞-3➞-5➞-7</pre>
</td>
<td>
Expand All @@ -305,8 +305,8 @@ An observable produces values over time. An array is created as a static set of
<tr>
<td><pre>reduce()</pre></td>
<td>
<pre>obs.scan((s,v)=> s+v, 0)</pre>
<pre>➞1➞3➞6➞11➞18</pre>
<pre>obs.pipe(reduce((s,v)=> s+v, 0))</pre>
<pre>➞18</pre>
</td>
<td>
<pre>arr.reduce((s,v) => s+v, 0)</pre>
Expand Down