Rule returning multiple events
Hello,
thanks for this great lib! 👍
Is there a reason why the rule can't return multiple events when it succeed ?
@jgoux thanks, you're welcome!
No reason I can think of off the top of my head. Perhaps we'll look at adding this in a future release if there's enough demand.
In the meantime, you may be able to work around this by listing multiple events in the params:
let rule = {
conditions: {
/* ... */
},
event: {
type: 'multiple-events',
params: {
event1: {
/* any additional event 1 parameters */
},
event2: {
/* any additional event 2 parameters */
}
}
}
}
You would of course need to write a few lines of logic for handling the 'multiple-events' payload
Indeed, it works well that way too. 👍 (I pass an array as the params)
event: {
type: 'SUCCESS',
params: [
{
type: 'INDUIRE_RESULTAT',
params: {
analyse: 'URFIN',
resultat: 'F'
}
},
{
type: 'INDUIRE_RESULTAT',
params: {
analyse: 'FOO',
resultat: 'BAZ'
}
}
]
}
I can live with it for now, thanks for the tip @CacheControl :D
Going to close this out as it doesn't seem to be gaining much traction, and the workaround has been reported to be successful.
Hi @CacheControl , not sure if this is obsolete, but we at riskine would definitely love the feature discussed here. Cheers, Johannes
Would greatly appreciate multi-event capability as well.
Just a note, that the workaround proposed here would be incompatible with some new functionality that relies on the correct use of the params for a single event, e.g. Support Facts in Events.
@honzabit This should still work, you just won't get the new feature. I'm reopening this issue and putting it into a version 7 wish list since it's going to need to be a breaking change.
@chris-pardy - do we have something like pairing of conditions and events e.g condition 1 is successful, return event 1, condition 2 is successful, return event 2. Probably we are trying to implement something similar to Drools, which can process excel sheet as a set of separate conditions and separate output. [ { "Facts": { "name": "Kashif" } }, { "Condition": { "any": [ { "fact": "name", "operator": "equal", "value": "Kashif" } ] }, "Event": { "Result": { "Message": "Facts equal to Kashif" } } }, { "Condition": { "any": [ { "fact": "name", "operator": "notEqual", "value": "Kashif" } ] }, "Event": { "Result": { "Message": "Name not equal to Kashif" } } } ]