Foreword |
|
xiii | |
Preface |
|
xv | |
Acknowledgments |
|
xvii | |
About This Book |
|
xix | |
About The Authors |
|
xxiv | |
About The Cover |
|
xxv | |
Part 1: Understanding Streams |
|
|
|
3 | (25) |
|
1.1 Synchronous vs. asynchronous computing |
|
|
5 | (7) |
|
Issues with blocking code |
|
|
5 | (1) |
|
Non-blocking code with callback functions |
|
|
6 | (1) |
|
Understanding time and space |
|
|
7 | (2) |
|
Are callbacks out of the picture? |
|
|
9 | (2) |
|
|
11 | (1) |
|
1.2 Better callbacks with Promises |
|
|
12 | (2) |
|
1.3 The need for a different paradigm |
|
|
14 | (3) |
|
1.4 The Reactive Extensions for JavaScript |
|
|
17 | (9) |
|
Thinking in streams: data flows and propagation |
|
|
17 | (1) |
|
Introducing the RxJS project |
|
|
18 | (1) |
|
|
19 | (2) |
|
Abstracting the notion of time from your programs |
|
|
21 | (2) |
|
Components of an Rx stream |
|
|
23 | (3) |
|
1.5 Reactive and other programming paradigms |
|
|
26 | (1) |
|
|
27 | (1) |
|
|
28 | (33) |
|
2.1 Functional programming as the pillar of reactive programming |
|
|
29 | (12) |
|
|
30 | (8) |
|
|
38 | (3) |
|
2.2 Stream's data-driven approach |
|
|
41 | (2) |
|
2.3 Wrapping data sources with Rx.Observable |
|
|
43 | (10) |
|
Identifying different sources of data |
|
|
43 | (1) |
|
Creating RxJS observables |
|
|
44 | (2) |
|
When and where to use RxJS |
|
|
46 | (3) |
|
|
49 | (4) |
|
2.4 Consuming data with observers |
|
|
53 | (7) |
|
|
53 | (2) |
|
Creating bare observables |
|
|
55 | (2) |
|
|
57 | (3) |
|
|
60 | (1) |
|
|
61 | (24) |
|
3.1 Evaluating and cancelling streams |
|
|
62 | (7) |
|
Downside of eager allocation |
|
|
62 | (2) |
|
Lazy allocation and subscribing to observables |
|
|
64 | (1) |
|
Disposing of subscriptions: explicit cancellation |
|
|
65 | (2) |
|
Cancellation mismatch between RXJS and other APIs |
|
|
67 | (2) |
|
3.2 Popular RxJS observable operators |
|
|
69 | (8) |
|
Introducing the core operators |
|
|
70 | (7) |
|
3.3 Sequencing operator pipelines with aggregates |
|
|
77 | (6) |
|
Self-contained pipelines and referential transparency |
|
|
77 | (3) |
|
Performance advantages of sequencing with RxJS |
|
|
80 | (3) |
|
|
83 | (2) |
|
4 It's about time you used RxJS |
|
|
85 | (34) |
|
4.1 Why worry about time? |
|
|
87 | (1) |
|
4.2 Understanding asynchronous timing with JavaScript |
|
|
88 | (6) |
|
|
88 | (1) |
|
|
88 | (2) |
|
The JavaScript timing interfaces |
|
|
90 | (4) |
|
4.3 Back to the future with RxJS |
|
|
94 | (7) |
|
|
98 | (1) |
|
|
99 | (2) |
|
|
101 | (10) |
|
|
101 | (7) |
|
|
108 | (3) |
|
|
111 | (5) |
|
|
116 | (3) |
Part 2: Observables In Practice |
|
119 | (90) |
|
5 Applied reactive streams |
|
|
121 | (30) |
|
5.1 One for all, and all for one! |
|
|
122 | (13) |
|
Interleave events by merging streams |
|
|
124 | (6) |
|
Preserve order of events by concatenating streams |
|
|
130 | (3) |
|
Switch to the latest observable data |
|
|
133 | (2) |
|
5.2 Unwinding nested observables: the case of mergeMap |
|
|
135 | (6) |
|
5.3 Mastering asynchronous streams |
|
|
141 | (5) |
|
5.4 Drag and drop with concatMap |
|
|
146 | (4) |
|
|
150 | (1) |
|
6 Coordinating business processes |
|
|
151 | (31) |
|
6.1 Hooking into the observable lifecycle |
|
|
152 | (7) |
|
Web hooks and the observer pattern |
|
|
153 | (1) |
|
|
154 | (5) |
|
6.2 Joining parallel streams with combineLatest and forkJoin |
|
|
159 | (11) |
|
Limitations of using Promises |
|
|
162 | (1) |
|
Combining parallel streams |
|
|
163 | (5) |
|
More coordination with forkJoin |
|
|
168 | (2) |
|
6.3 Building a reactive database |
|
|
170 | (11) |
|
Populating a database reactively |
|
|
172 | (3) |
|
|
175 | (2) |
|
Joining related database operations |
|
|
177 | (3) |
|
|
180 | (1) |
|
|
181 | (1) |
|
7 Error handling with RxJS |
|
|
182 | (27) |
|
7.1 Common error-handling techniques |
|
|
183 | (5) |
|
Error handling with try/catch |
|
|
183 | (1) |
|
Delegating errors to callbacks |
|
|
184 | (2) |
|
|
186 | (2) |
|
7.2 Incompatibilities between imperative error-handling techniques and functional and reactive code bases |
|
|
188 | (1) |
|
7.3 Understanding the functional error-handling approach |
|
|
189 | (4) |
|
7.4 The RxJS way of dealing with failure |
|
|
193 | (15) |
|
Errors propagated downstream to observers |
|
|
193 | (2) |
|
Catching and reacting to errors |
|
|
195 | (2) |
|
Retrying failed streams for a fixed number of times |
|
|
197 | (2) |
|
Reacting to failed retries |
|
|
199 | (9) |
|
|
208 | (1) |
Part 3: Mastering RxJS |
|
209 | (96) |
|
|
211 | (34) |
|
8.1 Introducing hot and cold observables |
|
|
212 | (5) |
|
|
212 | (3) |
|
|
215 | (2) |
|
8.2 A new type of data source: WebSockets |
|
|
217 | (4) |
|
A brief look at WebSocket |
|
|
218 | (1) |
|
A simple WebSocket server in Node.js |
|
|
219 | (1) |
|
|
220 | (1) |
|
8.3 The impact of side effects on a resubscribe or a replay |
|
|
221 | (5) |
|
|
222 | (1) |
|
Replaying the logic of a stream |
|
|
222 | (2) |
|
Resubscribing to a stream |
|
|
224 | (2) |
|
8.4 Changing the temperature of an observable |
|
|
226 | (11) |
|
Producers as thermometers |
|
|
227 | (1) |
|
Making a hot observable cold |
|
|
228 | (2) |
|
Making a cold observable hot |
|
|
230 | (2) |
|
Creating hot-by-operator streams |
|
|
232 | (5) |
|
8.5 Connecting one observable to many observers |
|
|
237 | (6) |
|
|
237 | (3) |
|
|
240 | (2) |
|
|
242 | (1) |
|
|
243 | (2) |
|
9 Toward testable, reactive programs |
|
|
245 | (26) |
|
9.1 Testing is inherently built into functional programs |
|
|
246 | (4) |
|
9.2 Testing asynchronous code and promises |
|
|
250 | (5) |
|
|
250 | (3) |
|
|
253 | (2) |
|
9.3 Testing reactive streams |
|
|
255 | (3) |
|
9.4 Making streams testable |
|
|
258 | (2) |
|
9.5 Scheduling values in RxJS |
|
|
260 | (3) |
|
9.6 Augmenting virtual reality |
|
|
263 | (7) |
|
|
264 | (2) |
|
|
266 | (1) |
|
Refactoring your search stream for testability |
|
|
267 | (3) |
|
|
270 | (1) |
|
|
271 | (34) |
|
10.1 Building a basic banking application |
|
|
273 | (1) |
|
10.2 Introduction to React and Redux |
|
|
274 | (12) |
|
Rendering UI components with React |
|
|
274 | (10) |
|
State management with Redux |
|
|
284 | (2) |
|
10.3 Redux-ing application state |
|
|
286 | (4) |
|
|
286 | (1) |
|
|
287 | (3) |
|
10.4 Building a hot RxJS and Redux store adapter |
|
|
290 | (1) |
|
10.5 Asynchronous middleware with RxJS Subject |
|
|
291 | (11) |
|
|
294 | (2) |
|
Building epic, reactive middleware |
|
|
296 | (6) |
|
10.6 Bringing it all home |
|
|
302 | (2) |
|
|
304 | (1) |
|
|
304 | (1) |
Appendix A: Installation Of Libraries Used In This Book |
|
305 | (5) |
Appendix B Choosing An Operator |
|
310 | (5) |
Index |
|
315 | |