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

Dispatch store action from an isolate callback? #172

Open
AAverin opened this issue Mar 6, 2020 · 1 comment
Open

Dispatch store action from an isolate callback? #172

AAverin opened this issue Mar 6, 2020 · 1 comment

Comments

@AAverin
Copy link

AAverin commented Mar 6, 2020

I am using flutter_downloader package to download some big files from the network in a nice manner.
When download task finishes library calls it's static download callback in a background isolate that is then uses ReceivePort to send a message to the main thread(isolate).

Problem is, all the code around this is now written in a singleton Manager class that is not a Widget.
When message that task download finished is published I need to somehow dispatch a store event that my download is finished so I could update UI properly.

How can I do that?

@AAverin AAverin changed the title Dispatch store action from an isolate callback>? Dispatch store action from an isolate callback? Mar 6, 2020
@raulccabreu
Copy link

You can use a middleware solve this, they are redux way to handle async and another system calls.

Here a doc on how to use middlewares, from redux.dart: https://github.com/fluttercommunity/redux.dart/blob/master/doc/async.md

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