First thing first - What is RXJS ?
So, lets understand this with a peace of code.
We have an array named source and on it we apply higher order functions like Filter (to get the elements which are odd), Map (to edit the result) and finally ForEach loop (where we will iterate through each element and print it to the result.).
So far so good, here is the output -
Now, lets add the Observable feature of RxJS. This Observable feature is defined to make things asynchronous. So lets try it.
We applied the same higher order function, but observed the same output. Wondering why .? Lets see another code -
Did we just observe the asynchronous behavior. Lets understand the code. We have an interval set of 500 over a take of 6 (0,1,2,3,4,5)
This interval when defined using observable, makes sure that the instance runs asynchronously within the defined interval.
Subscribe to Prashant Bansal
Get the latest posts delivered right to your inbox