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

Wait for FSM to be in State #172

Open
MaZderMind opened this issue Mar 6, 2022 · 0 comments
Open

Wait for FSM to be in State #172

MaZderMind opened this issue Mar 6, 2022 · 0 comments

Comments

@MaZderMind
Copy link

I read through the Docs for a way to externally wait for the FSM to reach a specific state (for example wait for an idle-State before tearing the connection down). This would either run directly if the FSM is already in this state or defer for the next transition to that state.

I had to do this in consumer-Code like this:

  function disconnectOnIdle() {
    …
  }

  if(connection.state === 'idle') {
    disconnectOnIdle();
  }
  else {
    console.log('Waiting for Idle-State…');
    connection.on("transition", data => {
      if(data.toState === 'idle') {
        disconnectOnIdle();
      }
    });
  }

But I think this Code is rather convoluted and such a requirement should be supported by the FSM class. by providing a Callback-Method like connection.onState('idle', () = { … }).

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