I am using Angular 5 HttpClient to send requests to a server and store the responses in a Datastore Service.
In our scenario, different APIs can be used, that respond with the same kind of data. When the user chooses to load data from another API: 1. the requests get unsubscribe using takeUntil, 2. the datastore gets emptied, 3. the data from the new API is fetched.
Yet pending requests at the time of unsubscription keep on bringing responses. As a result, data from both the former and the latter API end up in the datastore... Unfortunate.
Is it what is to be expected from an unsubcribed pending request? That it is like throwing a ball above once head and once it has been thrown, there is no way to make it stop in midair?
If that is the case, what method is generally used in such a scenario to ignore these unwanted responses?