Skip to content

Sending a message to my Sandbox App from a background job #937

Answered by tarkah
randall-coding asked this question in Q&A
Discussion options

You must be logged in to vote

The best way to implement a background task with iced is to implement your task as an iced_native::subscription::Recipe and add it as a subscription with Application::subcription / Subscription::from_recipe.

This task will get continually polled and you'll be able to send messages directly to your App's Message / update.

You can see a comprehensive example of how this done for a task that downloads something, and continually sends updates of the download progress here:

https://github.com/hecrj/iced/blob/master/examples/download_progress/src/download.rs

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@randall-coding
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@randall-coding
Comment options

Answer selected by hecrj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #923 on June 28, 2021 18:33.