-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
If local storage is not used, the state_machine macro could generate the following State enum, which would make the usage more straightforward and clear:
pub enum State { LedOn, NotBlinking { b }, LedOff }
impl State {
fn led_on() -> Self { Self::LedOn } // no local storage
fn not_blinking(b) -> Self { Self::NotBlinking { b } } // with local storage
fn led_off() -> Self { Self::LedOff }
}
Call Handler :
match self {
State::LedOn => Blinky::led_on(event), // no local storage
State::NotBlinking { b } => Blinky::not_blinking(b, event), // Uses local storage
State::LedOff => Blinky::led_off(event),
_ => statig::Response::Super
}
Get State :
match state_machine.state() {
State::LedOn => {} // no local storage or extra parameters
State::NotBlinking { b } => {}
State::LedOff => {}
}
This approach would enhance clarity and improve the developer experience by making state transitions and handling more intuitive.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers