-
Notifications
You must be signed in to change notification settings - Fork 43
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
Status emission problem #38
Comments
which version you are using, in version 2.0.1, you can use observeDownloadById You can see the function in DownloadManager, added distinctUntilChanged so it is only observed again when something changes in DownloadModel |
Thanks for your time. I alredy did this but it wont work here is the code. suspend fun Context.myKetchObserver(id : Int, callback:(DownloadModel) -> Unit) { |
Are you cancelling the scope from which you are calling it, before downloading it again? Since observeDownloadById is returning the flow every time you call it, it will start observing, so if your scope is not cancelled, it will call multiple times. For e.g: something like this,
|
When I start download something and then i cancel after 2 to 3 second after repeating this 2 to 3 time in the 4th time when I finally downloaded that file all the previous emission of those file also emitted like PROGRESS 4 times, SUCCESS 4 times below
Logs :
collectLatest ketch QUEUED
collectLatest ketch QUEUED
collectLatest ketch QUEUED
collectLatest ketch QUEUED
collectLatest ketch STARTED
collectLatest ketch STARTED
collectLatest ketch STARTED
collectLatest ketch STARTED
collectLatest ketch PROGRESS
collectLatest ketch PROGRESS
collectLatest ketch PROGRESS
collectLatest ketch PROGRESS
collectLatest ketch SUCCESS
collectLatest ketch SUCCESS
collectLatest ketch SUCCESS
collectLatest ketch SUCCESS
What I expect is after QUEUED status all the STARTED, PROGRESS and SUCCESS should be called only once.
The text was updated successfully, but these errors were encountered: