Rxjs in Action

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

A growing flood of data is aimed at JavaScript applications, and they need be ready for it. As more and more data is received, applications must scale to stay operational. There's also the problem of latency when data has to be fetched from remote locations. RxJS, or Reactive Extensions for JavaScript, is a library for transforming, composing, and consuming streams of data. RxJS combines reactive and functional programming to give an extensible, asynchronous event handling system for JavaScript.

RxJS in Action gives readers the development skills they need to create reactive applications with RxJS. This book is full of theory and practical examples that build on each other and help readers begin thinking in a reactive manner. The book begins by teaching the fundamentals of functional programming, and dives in to the basics of RxJS and what it means to be reactive. Next, it teaches how to build real-world applications with RxJS. The last part of the book tackles the advanced topics to take the reader's reactive programming skills to the next level, as they will learn how to deal with error handling, unit testing, and the role of RxJS when combined with frameworks such as Angular.js or Cycle.js. Examples in the book use RxJS 5, the latest version of RxJS built with an eye on performance and simplicity.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

Author(s): Daniels, P.P.; Atencio, L.
Edition: 1
Publisher: Manning Pub.
Year: 2017

Language: English
Pages: 400

brief contents
contents
foreword
preface
acknowledgments
about this book
Road map
Who should read this book
How to use this book
Examples and source code
Author Online
about the authors
about the cover
Part 1 Understanding streams
1 Thinking reactively
1.1 Synchronous vs. asynchronous computing
1.1.1 Issues with blocking code
1.1.2 Non-blocking code with callback functions
1.1.3 Understanding time and space
1.1.4 Are callbacks out of the picture?
1.1.5 Event emitters
1.2 Better callbacks with Promises
1.3 The need for a different paradigm
1.4 The Reactive Extensions for JavaScript
1.4.1 Thinking in streams: data flows and propagation
1.4.2 Introducing the RxJS project
1.4.3 Everything is a stream
1.4.4 Abstracting the notion of time from your programs
1.4.5 Components of an Rx stream
1.5 Reactive and other programming paradigms
1.6 Summary
2 Reacting with RxJS
2.1 Functional programming as the pillar of reactive programming
2.1.1 Functional programming
2.1.2 The iterator pattern
2.2 Stream’s data-driven approach
2.3 Wrapping data sources with Rx.Observable
2.3.1 Identifying different sources of data
2.3.2 Creating RxJS observables
2.3.3 When and where to use RxJS
2.3.4 To push or not to push
2.4 Consuming data with observers
2.4.1 The Observer API
2.4.2 Creating bare observables
2.4.3 Observable modules
2.5 Summary
3 Core operators
3.1 Evaluating and cancelling streams
3.1.1 Downside of eager allocation
3.1.2 Lazy allocation and subscribing to observables
3.1.3 Disposing of subscriptions: explicit cancellation
3.1.4 Cancellation mismatch between RxJS and other APIs
3.2 Popular RxJS observable operators
3.2.1 Introducing the core operators
3.3 Sequencing operator pipelines with aggregates
3.3.1 Self-contained pipelines and referential transparency
3.3.2 Performance advantages of sequencing with RxJS
3.4 Summary
4 It’s about time you used RxJS
4.1 Why worry about time?
4.2 Understanding asynchronous timing with JavaScript
4.2.1 Implicit timing
4.2.2 Explicit timing
4.2.3 The JavaScript timing interfaces
4.3 Back to the future with RxJS
4.3.1 Propagation
4.3.2 Sequential time
4.4 Handling user input
4.4.1 Debouncing
4.4.2 Throttling
4.5 Buffering in RxJS
4.6 Summary
Part 2 Observables in practice
5 Applied reactive streams
5.1 One for all, and all for one!
5.1.1 Interleave events by merging streams
5.1.2 Preserve order of events by concatenating streams
5.1.3 Switch to the latest observable data
5.2 Unwinding nested observables: the case of mergeMap
5.3 Mastering asynchronous streams
5.4 Drag and drop with concatMap
5.5 Summary
6 Coordinating business processes
6.1 Hooking into the observable lifecycle
6.1.1 Web hooks and the observer pattern
6.1.2 Hooked on observables
6.2 Joining parallel streams with combineLatest and forkJoin
6.2.1 Limitations of using Promises
6.2.2 Combining parallel streams
6.2.3 More coordination with forkJoin
6.3 Building a reactive database
6.3.1 Populating a database reactively
6.3.2 Writing bulk data
6.3.3 Joining related database operations
6.3.4 Reactive databases
6.4 Summary
7 Error handling with RxJS
7.1 Common error-handling techniques
7.1.1 Error handling with try/catch
7.1.2 Delegating errors to callbacks
7.1.3 Errors and Promises
7.2 Incompatibilities between imperative error-handling techniques and functional and reactive code bases
7.3 Understanding the functional error-handling approach
7.4 The RxJS way of dealing with failure
7.4.1 Errors propagated downstream to observers
7.4.2 Catching and reacting to errors
7.4.3 Retrying failed streams for a fixed number of times
7.4.4 Reacting to failed retries
7.5 Summary
Part 3 Mastering RxJS
8 Heating up observables
8.1 Introducing hot and cold observables
8.1.1 Cold observables
8.1.2 Hot observables
8.2 A new type of data source: WebSockets
8.2.1 A brief look at WebSocket
8.2.2 A simple WebSocket server in Node.js
8.2.3 WebSocket client
8.3 The impact of side effects on a resubscribe or a replay
8.3.1 Replay vs. resubscribe
8.3.2 Replaying the logic of a stream
8.3.3 Resubscribing to a stream
8.4 Changing the temperature of an observable
8.4.1 Producers as thermometers
8.4.2 Making a hot observable cold
8.4.3 Making a cold observable hot
8.4.4 Creating hot-by-operator streams
8.5 Connecting one observable to many observers
8.5.1 Publish
8.5.2 Publish with replay
8.5.3 Publish last
8.6 Summary
9 Toward testable, reactive programs
9.1 Testing is inherently built into functional programs
9.2 Testing asynchronous code and promises
9.2.1 Testing AJAX requests
9.2.2 Working with Promises
9.3 Testing reactive streams
9.4 Making streams testable
9.5 Scheduling values in RxJS
9.6 Augmenting virtual reality
9.6.1 Playing with marbles
9.6.2 Fake it ’til you make it
9.6.3 Refactoring your search stream for testability
9.7 Summary
10 RxJS in the wild
10.1 Building a basic banking application
10.2 Introduction to React and Redux
10.2.1 Rendering UI components with React
10.2.2 State management with Redux
10.3 Redux-ing application state
10.3.1 Actions and reducers
10.3.2 Redux store
10.4 Building a hot RxJS and Redux store adapter
10.5 Asynchronous middleware with RxJS Subject
10.5.1 RxJS subjects
10.5.2 Building epic, reactive middleware
10.6 Bringing it all home
10.7 Parting words
10.8 Summary
Appendix A Installation of libraries used in this book
Installing the example projects
Installing RxJS
Installing Ramda.js
Installing PouchDB
Installing Moment.js
Installing Google client APIs
Using the Bitly Web API
Installing Mocha
Installing Chai.js
Installing React.js
Installing React-Bootstrap
Installing Redux.js
Appendix B Choosing an operator
index
Symbols
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
R
S
T
U
V
W
X
Z