EventState and OnEvent actions relation to eventRef #524
-
In the example given in the specs, {"onEvents": [{
"eventRefs": ["HighBodyTemperature", "HighBloodPressure"],
"actions": [{ "functionRef": {
"refName": "SendTylenolOrder",
"arguments": {
"patient": "${ .patientId }" }}},
{ "functionRef": {
"refName": "CallNurse",
"arguments": {
"patient": "${ .patientId }"}}}] }]
} Is there a relationship between items in eventRef and actions? ie. when Exclusive is True, if the event received is "HighBodyTemperature", i call function "SendTylenolOrder", but if the event is "HighBoodPressure" i call function "CallNurse"? Of if i received either event i will call both "SendTylenolOrder" and "CallNurse"? Looking at the example i tend to think there is some relationship Given that EventState has N OnEvents which it must wait for and each OnEvent has M EventRefs - does it mean i have to wait for all (N * M) eventRefs before the EventState is completed? Also, if Exclusive is True, and if i received event "HighBodyTemperature", does EventState still continue to wait for "HighBloodPressure"? i.e. when should i stop waiting for this particular OnEvent or consider this OnEvent completed? Continuing, if Exclusive is True, and i need to wait for all eventRefs, does it mean that i will call the two functions twice? i.e. i call both "SendTylenolOrder" and "CallNurse" once when i receive "HighBodyTemperature" and another time when i receive "HighBloodPressure"? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
@globalflea The snippet you submitted will trigger both onEvents:
- eventsRefs:
- HighBodyTemperature
actions:
- refName: CallNurse
arguments:
patient: ${ .patientId }
- eventsRefs:
- HighBloodPressure
actions:
- refName: SendTylenolOrder
arguments:
patient: ${ .patientId }
When
It depends of the value supplied to
No. Either consumed events should kill the trigger. Other non-consumed events are discarded.
No, in any cases, you are gonna fire the actions of a given trigger once and only once. What Hope it answers your question. |
Beta Was this translation helpful? Give feedback.
-
To be sure I understand, let say I have an EventState with two OnEvent (OE-A and OE-B) and each of them have two EventRef (so, for OE-A -> OE-A.1 & OE-A.2; OE-B -> OE-B.1 & OE-B.2) If exclusive is true and the EventState received an event that matches OE-B.1, I conclude that OE-B is completed and the EventState will no longer wait for an event that matches OE-B.2. However, the EventState will continue to wait for events related to OE-A. Is this understanding correct? If exclusive is false, the EventState will continue to wait for events that will match the remaining 3 events? Ie the EventState will wait till it receives events that matches all OE-A.1, OE-A.2 and OE-B.2. correct? |
Beta Was this translation helpful? Give feedback.
-
@globalflea For most things, that's my understanding of it, yes. For the first case, though, in my implementation the trigger is as well considered implicitly exclusive (the behavior is inherited from the EventState). Is it how it's designed to work, @tsurdilo ? |
Beta Was this translation helpful? Give feedback.
-
No, the event state does not continue to wait for events related to OE-A. Once one of the eventRefs "fire", regardless of exclusive, the state performs actions and completes. exclusive deals with each individual "eventsRefs" definition, not across them.
No, if exclusive is false, for OE-A to "fire" it needs A.1 and A.2, for OE-B to fire it needs B1 and B2 events. Hope this makes sense. |
Beta Was this translation helpful? Give feedback.
No, the event state does not continue to wait for events related to OE-A. Once one of the eventRefs "fire", regardless of exclusive, the state performs actions and completes. exclusive deals with each individual "eventsRefs" definition, not across them.