Closed
Description
Hello,I'm looking for a rule engine written in js,and I find this project easy to use,and following is my problem using the engine.
I add a rule,then run the engine per 1 second.
After 3 seconds,I remove the rule.
However,I still got "hello-world!" per second.
I think there need to be a remove rule test.
I have a look at the source code,the problem can be solved by adding this.prioritizedRules = null to removeRule.
Here is my code
let Engine = require('json-rules-engine').Engine
let Rule = require('json-rules-engine').Rule
let engine = new Engine()
let rule = new Rule({
conditions: {
all: [{
fact: 'displayMessage',
operator: 'equal',
value: true
}]
},
event: {
type: 'message',
params: {
data: 'hello-world!'
}
}
})
engine.addRule(rule)
engine.addFact('displayMessage', true);
engine.on('success', (event, almanac, ruleResult) => {
console.log(event.params.data)
})
setInterval(() => {
engine
.run()
}, 1000);
setTimeout(() => {
console.log('remove');
engine.removeRule(rule);
}, 3000)
Metadata
Metadata
Assignees
Labels
No labels