fromEventhelper function to create an observable of mouse click events:
subscribemethod, supplying a function (or object) - also known as an
observer. This is where you can decide how to react(-ive programming) to each event. Let's walk through what happens in the previous scenario when a subscription is created:
unsubscribewhich contains clean up
subscribea second time will create a new event listener:
Subjects(either explicitly or behind the scenes). More on that in a future article!
Arraymethods. For instance, if you want to transform emitted values from an observable source, you can use
pipefunction is the assembly line from your observable data source through your operators. Just like raw material in a factory goes through a series of stops before it becomes a finished product, source data can pass through a
pipe-line of operators where you can manipulate, filter, and transform the data to fit your use case. It's not uncommon to use 5 (or more) operators within an observable chain, contained within the
filteringoperators. Trying to track down a bug, or debug the flow of data through your observable stream? There are
utilityoperators that will do the trick. The operator categories include...
switchbased operators will turn off (unsubscribe) the current observable and turn on a new observable on emissions from the source. Switch operators are useful in situations you don't want (or need) more than one active observable at a time:
mergeMapoperator, which fires off a save request on each event: