StateMachine icon indicating copy to clipboard operation
StateMachine copied to clipboard

Question: only states and events (no side effects)

Open Dario-GoldenSpear opened this issue 3 years ago • 3 comments

Hi,

I have implemented and ad-hoc Bluetooth connection state machine based on states and events (no need for SideEffects / actions for the moment). I was thinking about switching that state machine to a version created using this library.

Is it possible to create such state machine, or as a minimum I should have at least 1 SideEffect (a dummy one for example)?

Thanks in advance.

Dario-GoldenSpear avatar May 24 '22 19:05 Dario-GoldenSpear

I think you can just use Nothing as the side-effect type, and just not pass them at all. (But then, I'm pretty new to this library too....)

dave08 avatar Aug 21 '22 09:08 dave08

Thanks for the suggestion @dave08 . I'm currently not working on this, but should I have some time to try it, I will confirm what you mention here.

Dario-GoldenSpear avatar Aug 22 '22 14:08 Dario-GoldenSpear

Using Nothing for type parameters which you aren't going to use is the correct way. This ensures that there is no way you can accidentally use a side-effect parameter anywhere in your statemachine definition. In transitionTo and anywhere else the effect parameter is optional and the Nothing type won't allow you to pass anything but null.

felixwiemuth avatar May 12 '24 10:05 felixwiemuth