You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to make a state machine that has a state which sends an Event from itself to the state machine. So this state is only doing an action, and then directly going to the next state.
Here is an example of what I would like to do:
enumEvent{SongDownloaded,}structMyStateMachine{player:MusicPlayer,}#[state_machine( initial = "State::idle()",)]implMyStateMachine{pubfnnew() -> Self{Self{player:MusicPlayer::new(),}}#[action]fnenter_download_song(&mutself){// [ Do other actions here ]self.player.download_song();// TODO: Here I want to go to the next state when the song is downloaded.// self.handle(&Event::SongDownloaded);}#[state]fndownload_song(event:&Event) -> Response<State>{match event {Event::SongDownloaded => Transition(State::playing())
_ => Super,}}// [ Other States ]}
Is it possible to send an event from a state? Or maybe am I doing something not very conventional with the library / the states machine in general? 😅
The text was updated successfully, but these errors were encountered:
Hi,
I'm trying to make a state machine that has a state which sends an Event from itself to the state machine. So this state is only doing an action, and then directly going to the next state.
Here is an example of what I would like to do:
Is it possible to send an event from a state? Or maybe am I doing something not very conventional with the library / the states machine in general? 😅
The text was updated successfully, but these errors were encountered: