I have a fragment that contains a RecyclerView that displays search results of users. Each user row in the RecyclerView contains a Follow/Unfollow button, which upon clicking, causing the hosting fragment to execute the appropriate network call in its Presenter (using MVP).
The problem that I'm looking to solve, is how to make sure that if a User is hammering away at a follow/unfollow button on a given row, that a network call is only executed once (I know this particular problem could be solved with switchmap if there was only one button). However, since each row has a button, I do not want prior network calls to be cancelled if for example the user clicks Follow on one user, and then right away clicks Follow on a different user.
Here is an example of what the Fragment looks like:
Any suggestions on how to accomplish this would be appreciated.
EDIT: forgot to mention I am using RxJava for networking and I'm hoping to use it for the solution