concept stream in category rxjs

This is an excerpt from Manning's book RxJS in Action.
First, we’ll explain some of the notation we use here. Streams are containers or wrappers of data very similar to arrays, so we used the array literal notation [] to symbolize this. Also, it’s common to use the $ suffix to qualify variables that point to streams. In the RxJS community, this is known as Finnish Notation, attributed to Andre Staltz, who is one of the main contributors of RxJS and Finnish.
In the previous chapter, we firmly rooted the notion that an observable is a sequence of events over time. You can think about it as the orchestrator or channel through which events are pushed and transformed. So far, we’ve discussed how to process observable sequences in isolation for the most part, and you learned how you could apply familiar operators over all the elements within an observable in the same way that you could with an array, irrespective of when those elements were emitted. Toward the end of the chapter, we briefly gave you some exposure to an RxJS operator called combineLatest(), which is used to combine streams. The reason for these discussions is that other than trivial examples, most of your programming tasks will involve the use of these operators so that the events from one stream propagate and cause a reaction somewhere else. This is where RxJS and the entire reactive paradigm begin to shine and set themselves superior to other conventional asynchronous libraries.
merge() can accept either an array or a variable number of streams that are to have their outputs merged into one. Thus, for the previous example, you can create a merged stream easily by passing both sources into the merge() operator, as shown in figure 5.3, for both static and instance forms.
Each stream, though independent, contributes to the overall output of the sequence. In more statically typed languages, the compiler will also often constrain the types that can go into a merge. This forces the input streams to have a uniform and predicable type for the output. In JavaScript, because these constraints don’t exist, it’s much easier to merge types that may not even be compatible. But this flexibility can result in some unexpected errors downstream when you’re looking to handle one type of event differently than the other. For this, one thing you could do is check your use cases to determine the type, as in the following listing. Again, going back to the touch and click streams, assume you need to print out the coordinates of both touch and click events.
Listing 5.1. Case matching event data resulting from merging mouse and touch streams
Rx.Observable.merge(mouseUp$, touchEnd$) #1 .do(event => console.log(event.type)) .map(event => { switch(event.type) { #2 case 'touchend': return {left: event.changedTouches[0].clientX, top: event.changedTouches[0].clientY}; case 'mouseup': return {left: event.clientX, top: event.clientY}; } }).subscribe(obj => console.log(`Left: ${obj.left}, Top: ${obj.top}`));