DEV Community

Discussion on: Explain (Timeline) Monads Like I'm Five

Collapse
 
jamesmh profile image
James Hickey

Timeline monad uses [functional] reactive programming.

Reactive programming is simply focusing on everything as a stream.

It's kinda like eating a 3-course meal - you have a stream (over time) of meals being given to you which you consume one-at-a-time.

Or, you might want to process your 3-course meal by combining all meals (waiting till they are all given to you) and then consuming them all-at-once.

Streams are basically an array of values that will be filled up as time moves forward. You will have some "observer" that is watching the stream. As values get "pushed" into that array (or stream), you will have some series of functions chained together that will transform and modify each value(s) however needed.

So, for example, you can batch these values easily, combine them, etc.

This is the default in AngularJs apps when trying to build views that reactively render based on changing data.

What's different from pub-sub? Nothing in my mind... you are subscribing to an observable which emits events whenever a new value is available. Your subscribed handler is invoked at that time.