What & Why

A library to streamline (no pun intented) our code through an Unidirectional Data Flow based on Functional Reactive Programming (aka FRP) & OOP Observer and Iterator Design Pattern.

Introduce a new Asynchronous Structure concerning the code, but also the Error-Handling
=> The chief goal consist to make it easier the composition of asynchronous code

Paradigm Tree!

schema show different programming paradigm family

JavaScript Multi-Paradigm or Zero-Paradigm?

Natural language has no dominant paradigm, and neither does JavaScript. Developers can select from a grab bag of approaches procedural, functional, and object-oriented and blend them as appropriate Angus Croll, If Hemingway Wrote JavaScript

Appendix side-effect

Simple example of a side-effect

Side-effects concern function which update/use:

Declarative vs Imperative

Example between declarative and imperative mindset

Applying these functions declaratively meaning your code expresses the what and not the how of what you’re trying to accomplish

RxJS Principles & Mindset

Functional Programming Principles & Mindset

functional programming listed principle

Reactive Programming Principles & Mindset

Excel example to demonstrate reactive programming mindset

        stream1$ = [1];
        stream2$ = [2];
        streamAdd$ = stream1$.concat(stream2$).reduce(sum); // => 3
        stream1$.push(10);
        // What's going on? Concerning streamAdd$???
    

FP + RP = FRP!

A stream is FRP => FP with steroids!!!

Current common Type solution

Single Value Multiple Value
Synchronous Char - Boolean - Number String - Array - Map
Asynchronous Promise Event Emitter - DOM Event

"Once upon a time... Asynchronous"

Asynchronous emphasis

JS Event-Loop schema

JavaScript Event-Loop: Here

Video

"Fin"

Callback


            getData(function(a){
                getMoreData(a, function(b){
                    getMoreMoreData(b, function(c){
                        getMoreMoreMoreData(c, function(d){
                            getMoreMoreMoreMoreData(d, function(e){
                                // and so on...
                            });
                        });
                    });
                });
            });
        
Horizontally nested calls => "Callback Hell"

Promises (FP principle)


            // Callback
            step1(value, function(data){
                step2(data, function(data2){
                    step3(data2, function(data3){
                    step4(data3, function(data4){
                        //INSTRUCTIONS ...
                    });
                    });
                });
            });

            // Promise
            step1.then(step2).then(step3).then(step4)
        
Promise schema
Promise returns an immutable, single postponed cached value

Promise drawbacks!

Don't worry stream is beautiful!

We have to shift our mindset to think in terms of streams, also known as functional sequences of events. RxJS implements under the hood through the use of familiar patterns such as Iterator and Observer.

Single Value Multiple Value
Synchronous Observable Observable
Asynchronous Observable Observable
Everything is a Stream meme

OOP DP

Two Behaviour DPs: Observer & Iterator

Observer

Observer UML Diagram

Here

Iterator

Iterator UML Diagram

Here