korken89 / smlang-rs

A State Machine Language DSL procedual macro for Rust
Apache License 2.0
193 stars 28 forks source link

Added transition_callback #77

Closed MartinBroers closed 2 weeks ago

MartinBroers commented 1 month ago

@ryan-summers Thanks for merging !66. I also like the function of a transition callback, so I went straight on it.

In terms of refinement and/or discussion, I am doubting mostly about this right now:

                                              self.context().transition_callback(&in_state, &out_state);
                                              self.state = Some(out_state);

Or should it be like this:

                                              self.state = Some(out_state);
                                              self.context().transition_callback(&in_state, &out_state);

So, call the transition callback after the internal state has been updated?

ryan-summers commented 1 month ago

I don't think it matters too much since the user will have both the input and output state directly in the method call as opposed to via the context.