Skip to content

Commit a664991

Browse files
committed
Add more examples
1 parent f6223ec commit a664991

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

examples/contactsList.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,29 @@ class ContactsList extends React.Component {
3232
<div>
3333
<h3>My Contacts</h3>
3434
<h4>Recently fetched contacts</h4>
35+
<pre>
36+
<code>
37+
{`
38+
recentContacts$ = myContacts$.pipe(startWith(null as Contact[] | null));
39+
<Subscribe>{recentContacts$.pipe(map(this.renderList))}</Subscribe>
40+
`.trim()}
41+
</code>
42+
</pre>
3543
<Subscribe>{this.recentContacts$.pipe(map(this.renderList))}</Subscribe>
44+
3645
<h4>All contacts</h4>
46+
<pre>
47+
<code>
48+
{`
49+
allContacts$ = myContacts$.pipe(
50+
scan((acc, contacts) => {
51+
return [...(acc || []), ...(contacts || [])];
52+
})
53+
);
54+
<Subscribe>{allContacts$.pipe(map(this.renderList))}</Subscribe>
55+
`.trim()}
56+
</code>
57+
</pre>
3758
<Subscribe>{this.allContacts$.pipe(map(this.renderList))}</Subscribe>
3859
</div>
3960
);

0 commit comments

Comments
 (0)