top-level "always" without conditions (onEvent) #1812
-
Is there a way to attach some action to all possible events in one place instead of doing it for each event separately? When I try to do this
It gives me an error
I know that there is an |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I've played around with it a little bit more and now I see that
So, In our case we need a side affect on event, but just before all its actions. We need a breadcrumb of what user intents to do before actually executing it. This is for our error handling system, it consist of user intents and exceptions. We would like to track event names from various state machines as intents. The So, the only way to do this today is to manually add one more action Maybe it's better to move |
Beta Was this translation helpful? Give feedback.
-
Yes there is, but you have to change the way you think about modeling the logic here. You essentially want two things to happen at the same time:
These seem like orthogonal concerns. So what should you use? Orthogonal (a.k.a. parallel) state nodes! {
type: 'parallel',
states: {
whatever: {
on: { '*': { actions: 'doSomething' } }
},
editor: {
initial: 'loading',
states: {
loading: {/* ... */},
// ...
}
}
}
} |
Beta Was this translation helpful? Give feedback.
Yes there is, but you have to change the way you think about modeling the logic here. You essentially want two things to happen at the same time:
These seem like orthogonal concerns. So what should you use? Orthogonal (a.k.a. parallel) state nodes!