Code Monkey home page Code Monkey logo

Comments (6)

CacheControl avatar CacheControl commented on May 14, 2024

@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.

from json-rules-engine.

ehusaint avatar ehusaint commented on May 14, 2024

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?

from json-rules-engine.

CacheControl avatar CacheControl commented on May 14, 2024

@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.

from json-rules-engine.

ehusaint avatar ehusaint commented on May 14, 2024

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.

from json-rules-engine.

CacheControl avatar CacheControl commented on May 14, 2024

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.

from json-rules-engine.

CacheControl avatar CacheControl commented on May 14, 2024

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

from json-rules-engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.