Custom futures executor with iced_futures#164
Merged
Conversation
They can be leveraged by shells to easily execute commands and track subscriptions.
This was referenced Jan 20, 2020
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #63.
Mainly, this PR introduces a configurable
Executorassociated type toApplicationby leveraging a new subcrate:iced_futures.The
ExecutortraitThe new
iced_futuressubcrate contains a newExecutortrait which is meant to allow shells to use different runtimes in a generic way.Feature flags can be enabled to obtain an implementation of this trait for well-known executors (
thread-pool,tokio,async-std, andwasm-bindgen-futuresfor now). This allows users to easily opt-in and choose their preferred runtime.For instance, let's say we want to use a
tokioruntime for ourApplication. We simply addiced_futuresto our dependencies and enable thetokiofeature:And we just plug it into our
Application:For convenience,
icedprovides anexecutor::Defaultwhich should resolve toThreadPoolin native platforms.wasm-bindgen-futuresin the Web.This basically replicates the behavior until now. Of course, if you choose to use your own executor, then it's up to you to ensure things stay cross-platform.
Additional amenities
The new subcrate also includes a bunch of new useful types:
subscription::Tracker, which can be used to track aSubscription, spawn or close streams accordingly, and broadcast shell events.Runtime, combining anExecutorand asubscription::Tracker. It can be used to easily spawn commands or run event subscriptions and get notified of the results!CommandandSubscriptiontypes, which have been moved fromiced_core.Self-contained examples
The
dev-dependenciesoficedwere getting out of hand. Most of the examples are very different and showcase distinct ways to use the library while combining it with other parts of the ecosystem.Because of this, it made sense to turn every example into a subcrate. As a consequence:
icedhas nodev-dependenciesnow! 🎉tour(the main featured example) only depends onicedandenv_logger.READMEwith a nice description and a GIF (I haven't recorded GIFs for all the examples yet!).