Closed xdma closed 2 years ago
Hi! This is intended behavior. DataState means that it is going to receive its data from Event that triggers this state. Initial state is entered implicitly when machine is started, so there is no data for it and this exception is thrown.
If you want just to store some data within your State I recommend subclassing State like this:
class SubclassState : DefaultState() {
val dataField = 0
}
Or please provide some info about your use case and what you want to archive having DataState as initial one.
As I is can see from your code sample EmergencyDialogStates.DialogState2
should be DefaultDataState<EmergencyEventData>
as you have a dataTransition<TimeoutEvent, EmergencyEventData>
that leads to this state.
Thank you, in the end, I solved the problem differently, in my case I need the original data to go through all internal nested states (DialogState1...) and be passed to the next states, so I accessed the original data using parent.data and this is enough at the moment
Hi! This is intended behavior. DataState means that it is going to receive its data from Event that triggers this state. Initial state is entered implicitly when machine is started, so there is no data for it and this exception is thrown.
If you want just to store some data within your State I recommend subclassing State like this:
class SubclassState : DefaultState() { val dataField = 0 }
Or please provide some info about your use case and what you want to archive having DataState as initial one.
yes, I got you, but as I said, this is not quite an initial state, but a nested initial state and I need the data from the data event that leads to the nested states to start, in any case, I solved the problem differently, thank you for the answers, in general I really like the library!
if you need some more info, let me know
I think you've chosen the right solution. Thank you!
I ran into a problem, if I use DefaultDataState as initial state (nested), the machine falls into error, when i change it to regular state (with no data), everything works fine
My data state:
Add as initial state (nested):
the data event used:
Exception when entering the state: