Skip to content
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

Rule Success/Failure Callback #16

Closed
ehusaint opened this issue Nov 9, 2016 · 6 comments
Closed

Rule Success/Failure Callback #16

ehusaint opened this issue Nov 9, 2016 · 6 comments
Projects

Comments

@ehusaint
Copy link

ehusaint commented Nov 9, 2016

Currently I'm getting the complete rule object back as part of rule failurecallback but for rule successCallback, I only get the event object. Is it possible to get the full rule object back as part of the successCallback.

@CacheControl
Copy link
Owner

@ehusaint That's not currently a feature - the event params are meant to store all information necessary for event handling, however we can certainly discuss making this possible. Can you elaborate a bit on why you're trying to access the rules object? I'd like to better understand the use case.

@ehusaint
Copy link
Author

ehusaint commented Nov 9, 2016

I wanted to access the priority of the rule on successCallback but on successCallback, I only get back the event params and on failureCallback, I get back the complete rule params. On successCallback, I wanted to the know the priority of that rule. Is that possible?

@CacheControl
Copy link
Owner

CacheControl commented Nov 9, 2016

@ehusaint Currently, you could do a little pseudo hack during runtime to attach the rule priority to the event, something like:

let rule = new Rule()
rule.setConditions({ /* ... */ })

rule.setPriority(10)

rule.setEvent({
  type: 'message',
  params: {
    data: 'hello-world!',
    rulePriority: rule.priority // store the rule priority on the event - `10`, in this example
  }
})

I realize this isn't ideal, and I think I agree that the rule object should be more accessible. I'll tag this as a feature request, however I'm about to go on holiday so it'll be a few weeks before I can provide a more elegant solution that what's above.

@ehusaint
Copy link
Author

ehusaint commented Nov 9, 2016

Got it. Yes, I can certainly use this as a workaround. But it would be certainly good to have that rule object more accessible as you mentioned. It would be great added feature.

Thanks for a quick response.

@CacheControl CacheControl moved this from Backlog to In Progress in Roadmap Apr 9, 2017
@CacheControl
Copy link
Owner

This feature is now available in 2.0.0-beta1. There is now a 3rd argument provided to both the success and failure events which contain a clone of the rule object. There's an example in pr #35 and some docs here and here

This a beta because I'm going to let it stew for a week or so to provide the various stakeholders an opportunity to give feedback. Please let me know if you have any input.

@CacheControl
Copy link
Owner

CacheControl commented Apr 21, 2017

Closing - access to rule properties now provided by the success/failure callback ruleResult argument in 2.0.0

@CacheControl CacheControl moved this from In Progress to Done in Roadmap Apr 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants