Skip to content

How do I propagate data to initial state of DataState? #59

Answered by nsk90
oyanyev asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, there is not such functionality like Data propagation, sorry. DataState/DataEvent are designed to be type safe API for passing data from event to its target state. Such propagation is out of their scope.

I suggest simply access innerInitial parent's data via direct reference to inner or parent property.

    "activeStates() not include nested machines states1" {

        class MoveEvent(override val data: Int) : DataEvent<Int>

        val outer = DefaultState("state_initial_1")
        val inner = defaultDataState("inner_state", defaultData = 0) // you can use this helper function
        val innerInitial = DefaultState("inner_initial")

        val sm = createStateMachine {
      …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@oyanyev
Comment options

Answer selected by oyanyev
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants