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.

Nothing like set_state("string") for transitions

See original GitHub issue
  1. Both transitions and states can be added via strings
  2. states can be reached via strings

Still I did not find a method in core.py to reach a transition via string. In my opinion a necessary feature to use transitions for APIs where triggers get passed via string.

Currently I’m doing

def _set_transition(self, name): eval('self.' +name+'()') self._set_transition("string")

to all my classes. But It would be great to have

self.machine.set_transition("string")

instead.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tyarkonicommented, Aug 26, 2016

Well, one limitation (though it’s actually a feature and not a bug) of set_state() is that it won’t cause any of the callbacks to fire. It’ll just immediately move the model to the specified state. So you don’t want to use set_state() if you need the callbacks to do stuff for you. I would probably go with the getattr approach above.

On further reflection though, I do think it probably makes sense to have an easy way to trigger events from the model by passing a string. While the approach I suggested above works fine, the user shouldn’t really have to reach inside the model that way. @aleneum and @wtgee, any objections to my adding a trigger() method to the Model?

0reactions
aleneumcommented, Aug 29, 2016

It was a welcome way to distract myself from something I (don’t) want to do today 😉. And closing tickets is fun (sorry for taking that away). BUT… stumbled upon a pygraphviz issue which occurs sometimes -_- Update: Best way to work around error message generation issues is to prevent errors 🙈

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why calling setState method doesn't mutate the state ...
Reason is setState is asynchronous, you can't expect the updated state value just after the setState , if you want to check the...
Read more >
Concurrent UI Patterns (Experimental) - React
Wrapping setState in a Transition​​ Press “Next” a few times. Notice it already feels very different.
Read more >
useState() vs setState() - Strings, Objects, and Arrays
The purpose of this article is to break down the use of the useState() React hook in an easy way using strings, objects,...
Read more >
How To Implement Smooth Transitions in React | by Rajat S
This is usually done by writing some CSS code, but there is another, and in my opinion, a better way to implement transitions...
Read more >
New feature: startTransition · Discussion #41 · reactwg/react-18
In a typical React app, most updates are conceptually transition updates. But for backwards compatibility reasons, transitions are opt-in. By ...
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