question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Transition in `onFinished`?

See original GitHub issue

Is it possible to create a transition in onFinished?

My main goal is to define a sets of nested states in different gradle modules and then combine them into a “big” state machine in another gradle module which also defines a transitions between those nested children when they finish.

// this function is defined in an independent gradle module,
// it has no knowldege of "parent", containing states, so it can't mention them
// in `transition` block of `done` state
fun IState.addStates() {
  lateinit var done: State

  initialState("a") {
    transition<Event> {
      targetState = done
    }
  }

  done = finalState("done")
}

// this function is defined in main(root) gradle module, which
// depends on the above module
fun main() {
  val machine = createStateMachine {
    lateinit var s2: State

    initialState("s1") {
      addStates()
      onFinished {
       // this is currently not possible, onFinished is a simple listener
        targetState = s2
      }
    }

    s2 = state("s2") {
      // ...
    }
  }
}

IIRC, something like this is possible in scxml and xstate.js. Is this possible in kstatemachine? Am I missing some other idiom which can be used to achieve this.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nsk90commented, Oct 6, 2022

Transitions on FinishedEvent will be released in v0.16.0

0reactions
dimsuzcommented, Oct 5, 2022

Oh! No, you are right. I have added this to catch_fish.success:

            success: {
              type: 'final',
              on: {
                'STUFF': 'wait'
              }
            },

And when in success state I can send this STUFF event, even though success is a final state!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use $transitions? - Stack Overflow
In new versions (>=1.0.0) the $state change events are deprecated, and now you have to use the $transitions instead... $transitions for new ...
Read more >
How to assign and transition conditionally? · Issue #850 - GitHub
Question /Feature Request Description: I am in the process of building a multi step form. When a field is filled, I am firing...
Read more >
chrome.webNavigation - Chrome Developers
The webNavigation API's onCommitted event has a transitionType and a transitionQualifiers property. The transition type is the same as used in the history...
Read more >
Creating Transitions and Timeline Animation in JavaFX
Learn how to create animation in JavaFX, including timelines, transitions, key frames, and rotation.
Read more >
Problem with killing and reinitialising ScrollTrigger after Single ...
I'm pretty sure the problem is related to the BarbaJS-like page transition the wordpress theme has implemented and that it doesn't calculate the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found