kiprasmel / xstate-cpp

[Discontinued] "XState" for the C++ land
MIT License
6 stars 0 forks source link

Return self once transitioning your state #2

Open kiprasmel opened 4 years ago

kiprasmel commented 4 years ago
struct StateMachine {
    const char *id;
    const char *initial;
    States states;
+   const char *value;

-   const char *transition(const char *currentState, const char *event) {
+   StateMachine *transition(const char *currentState, const char *event) {
        const char *nextState = this->states[currentState].on[event];
+       this->value = nextState;
-       return nextState;
+       return this;
    }
}