Reactive Programming - alexanderteplov/computer-science GitHub Wiki
Reactive programming is mostly like Functional programming where functions and data are combined with time and called streams. We can create a stream from anything: array, primitive value, etc. We can merge streams, composite them, have HoS (high order stream) which takes another stream as an input or gives as a result.
A stream is a sequence of ongoing events ordered in time. Streams can emit three things: a value (of some type), an error, or a "completed" signal. To capture these emits you subscribe to a stream passing a function called observers (Observer design pattern).
On top of that ideas, we have a bunch of functions to help us handle streams with all the power of functionality.
The most common example of RP in the JavaScript world is RxJS.
Pros:
- writing declarative code
- avoiding callback hell
- purity
- avoiding implementation details with a focus on business goals
Cons:
- only hard debugging
- making documentation
- memory consumption,
- time to start
- managing concurrency
- complexity of testing
- a learning curve