Subscriptions
Explore how to manage multiple subscriptions in RxJS to avoid redundant data requests. Learn to convert cold observables into hot ones with share and control data flow using publish and connect. This lesson teaches techniques for efficient multiplexing and lazy loading to improve reactive app performance.
We'll cover the following...
Sometimes we don’t want to trigger the creation logic every time another part of your application wants to listen to the result.
Consider an AJAX request that fetches a user object:
let user$ = ajax('/user');
Subscriptions
You might naively pass around user$ to all the components in your application, where all of the listeners happily subscribe and pull whatever information they need.
This solution works until the backend engineer comes chasing after us with a pile of excessive log files demanding to know why every page load makes seventeen requests to the /user endpoint.
Cold observables
Oops. That’s because observables are “cold” by ...