Skip to content

Rule returning multiple events #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jgoux opened this issue Feb 27, 2017 · 10 comments
Open

Rule returning multiple events #30

jgoux opened this issue Feb 27, 2017 · 10 comments
Milestone

Comments

@jgoux
Copy link

jgoux commented Feb 27, 2017

Hello,

thanks for this great lib! 👍

Is there a reason why the rule can't return multiple events when it succeed ?

@CacheControl
Copy link
Owner

CacheControl commented Feb 27, 2017

@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

@jgoux
Copy link
Author

jgoux commented Feb 28, 2017

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

@CacheControl
Copy link
Owner

Going to close this out as it doesn't seem to be gaining much traction, and the workaround has been reported to be successful.

@jseebacher
Copy link

Hi @CacheControl , not sure if this is obsolete, but we at riskine would definitely love the feature discussed here. Cheers, Johannes

@stephen-spiny
Copy link

Would greatly appreciate multi-event capability as well.

@honzabit
Copy link

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.

@chris-pardy chris-pardy reopened this Aug 25, 2023
@chris-pardy
Copy link
Collaborator

@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 chris-pardy added this to the version 7 milestone Aug 25, 2023
@kashifrahman
Copy link

@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"
}
}
}
]

@jonas-almen
Copy link

Is this becoming implemented ?

@brandoningli
Copy link

Any updates here? This would be extremely useful in a current use case. I'm currently having to create custom events that are combinations of other events in order to accommodate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants