Trying to understand where and how to generate multiple Command
s from 1 Event
#1999
Replies: 1 comment 5 replies
-
The way I understand it there are no Commands involved here. An iced Command is an asynchronous action that may dispatch a Message as a result or not. In here, you have a subscription which also may or may not dispatch Messages after each event, so you just need to deal with Messages. As far as I know you can only dispatch one at a time form a subscription, but that should be enough for any use case. For example, let's say you have 2 potential updates that you need to perform on your state depending on what was pasted to the clipboard; you could have 3 Messages to represent all combinations and dispatch only one of them:
You could also have just one Message with enough internal data for the Does that make sense? |
Beta Was this translation helpful? Give feedback.
-
I would like to listen to the keyboard CTRL+V event, then depending on what is in the clipboard, evoke multiple different
update
s.I am confused how to do this. I do see both
Subscription
andCommand
have abatch
method, but I am confused how to create severalCommand
s.Currently inside of the
subscription
method, I usesubscription::events_with
, where after I detect the CTRL+V, my 1Message
will be converted into 1Command<Message>
.So a few questions:
subscription
method or theupdate
method?Command
s?I see there is a
Command::perform
method for example, but I am confused about having to pass in a function into it.Current code for reference:
Beta Was this translation helpful? Give feedback.
All reactions