-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Is it possible to send a Message
manually?
#1172
Comments
The answer is yes-but-actually-no It is possible to just call your update function, and just pass the message you want to. But don't!This is only a side effect of the current implementation of the elm architechture being ported to rust. Manually passing messages breaks all guarentees that the elm architechture provides. |
Alright, then I won't :-) So are Subscriptions and Recipes the only way? I've found it hard to figure out how to convert collections and iterators into these, even from the |
Could you elaborate a bit on your use case? |
I am specifically working on an emulator which sends a bunch of messages to indicate what's going on (memory writes, etc...). But fundamentally, I am doing:
How can I turn the stream of messages received by |
Ah ya, this is possible, and a planned feature, just not implemented yet. What needs to be done is Those links are from the download example. Your implementation would have to subscribe to the mpsc by creating a recipe. You probably would want to use If you get it working, a PR to simplify the API or an example here and or here would be awesome! Asking how to subscribe to an mpsc is really common. |
Yes, I am familiar with all these steps, but the devil is in the details, and in particular, returning that I think even a simple example of how to turn an iterator into that I'll keep digging. |
I made some progress and almost got everything to compile, but I'm now hitting a wall and I'm wondering if it might be a problem in Here is my implementation of
and the error:
All the generic types match except the Am I missing something? Maybe I |
Here is a fully contained example showing the compiler error:
|
Any thoughts on how to get this to compile? |
I tried getting it to compile to no avail, but I think that's me not quite understanding your needs. I have a working subscription that uses an mpsc here: https://github.com/atlanticaccent/starsector-mod-manager-rust/blob/e1e35ca6d5824eead3146da724cb30cf402d0f77/src/gui/installer.rs The more I think about it, you may want to consider doing it as I have above, and create a complete State struct which contains your rx, and effectively handle all async operations (including mpsc instantiation) from within the subscription itself. |
Thanks, I'll take a look. But still, isn't it weird that we can't get this to compile? It should be possible. All I'm doing in this code is convert channels into a subscription/recipe, it should be a trivial code sample. |
I am aware that regular way to do this is to use
Subscriptions
andRecipes
, but is it possible to send aMessage
manually from "outside" the iced regular functions?The text was updated successfully, but these errors were encountered: