Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to stop an async task launched by the handler #38

Open
BraisGabin opened this issue May 31, 2021 · 2 comments
Open

How to stop an async task launched by the handler #38

BraisGabin opened this issue May 31, 2021 · 2 comments

Comments

@BraisGabin
Copy link

I have a serch that each time that you type a character it launches a request. The problem is that if I don't cancel I could have this race condition:

  • Action Search "mv"
  • Action Search "mvf"
  • Mutation with items from "mvf"
  • Mutation with items from "mv"

At the end the user sees the results of "mv" instead of "mvf".

If I can cancel the collection of the current old flow I would fix it. Maybe there is other way to avoid this problem. I tried out this one: badoo/MVICore#68 (comment) but Flow doesn't have a takeUntil.

@BraisGabin
Copy link
Author

If someone see this. A workaround was posted in the last link of the previous post. Basically is an impelemntation of the operator takeUntil for Flow

@pedroql
Copy link
Owner

pedroql commented Jun 8, 2021

Hi,

This is indeed an interesting scenario (and I've needed this in other MVI libraries). I haven't had time to look into this so I don't yet know if it would be easy to plug this functionality or if it would require more significant changes. I'll try to have a look and post something, but I don't know when that will be possible.

Anyway, the source is relatively small so I would suggest you try it yourself. I'm happy to help too (within my time availability).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants