Nothing like set_state("string") for transitions
See original GitHub issue- Both transitions and states can be added via strings
- 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:
- Created 7 years ago
- Comments:9 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 useset_state()
if you need the callbacks to do stuff for you. I would probably go with thegetattr
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?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 🙈