Comments (6)
@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.
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.
@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.
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.
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.
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)
- is this project still active HOT 9
- Not able to resolve JsonPath when it includes a where condition HOT 1
- Operator availability - between operator HOT 1
- OnSuccess/OnFailure properties as part of the rule - Security Issue
- Slow performance while having large array of facts. HOT 9
- How to feed engine multiple facts as array! HOT 1
- Complex rule for the fact HOT 2
- woops HOT 1
- Feat: Type-safety using a FactTypeMapping HOT 1
- Is it possible to make sure that a fact triggers at most one rule? HOT 2
- Uncaught TypeError: (0 , _hashIt2.default) is not a function HOT 8
- Error: Cannot find module 'lodash' HOT 1
- problems with the execution of my rules HOT 4
- Example issue - undefined parameter HOT 1
- RuleResult class missing from type declarations HOT 1
- What the best way to launch the rule engine
- Parent child rule
- Ability to stop rules execution after success for array of inputs
- How to create multiple 'aggregate' facts on a 'parent' object calculated from child objects (composition)
- BigInt value is not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-rules-engine.