Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Sideeffects #32

Closed
geertijewski opened this issue Jun 23, 2020 · 1 comment
Closed

Multiple Sideeffects #32

geertijewski opened this issue Jun 23, 2020 · 1 comment

Comments

@geertijewski
Copy link

It would be nice if the state machine could allow for multiple side effects on an transition. For example one (always used) side effect of logging the transition and one highly specialized for the stateA ---> stateB transition (caused by eventC)

I image the call site to look something like this:

 state<MachineState.INOPERATIVE> {
        on<Event.OnPacket> {
            if (it.fancyVariable === 123) {
                transitionTo(MachineState.STARTING,
                        listOf(SideEffect.FrobnicateBar(it.requestTime),
                               SideEffect.WriteStateTransition()))
            } else {
                dontTransition()
            }
        }
    }

To also allow the old style of only specifying one side effect it seems like I would need to overload StateMachine.StateDefinitionBuilder.transitionTo() and dontTransition()

I would be happy to try this (given some pointers on where to start).

@geertijewski
Copy link
Author

It seems like the way to solve this in this lbirary is to put the general case in onTransition before then matching to the actual side effeect and doing the specific action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant