Chaotic search and delayed results mess in front-end

Robertas Vilkisius
1 min readJan 28, 2021

Is your service not so responsive? Some requests can be heavier and some lighter. We can try to improve service performance by allocating more resource but this never be a right solution. This is a pretty common case nowadays. Even if your application performing fine, you should ensure that in such a case, your application would work as expected.

If you deal with a mobile application where users execute a search chaotically, your application can start choking. For example, the first user’s request got delayed and user made a new one. So, the second arrived before the first one and was printed. It would be fine if not the first delayed request that was added to the list later on. This type of result is wrong and you must ensure that your client sees what he expects. This might be solved by using RxJS switchMap().

switchMap() switches to the most recent observable and unsubscribes the previous one. As simple as that.

#nativescript #angular #rxjs #switchmap #front-end #back-end

--

--