-
Notifications
You must be signed in to change notification settings - Fork 181
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
checkin for rule attribute no-loop #181
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not work as expected, no-loop avoid only self-loop recursion.
function Message() {
this.state = 0;
}
var flow = nools.flow("noLoop1", function () {
this.rule("Rule 1: State from 0 to 1 and from 2 to nothing", { noLoop: true }, [Message, "m"], function (facts) {
var m = facts.m;
if(m.state == 0) {
m.state = 1;
this.modify(m);
} else {
// nothing
}
});
this.rule("Rule 2: State from 1 to 2", [Message, "m", "m.state == 1"], function (facts) {
var m = facts.m;
m.name = 'Hello World 2';
m.state = 2;
this.modify(m);
});
});
In this exemple, we expect firing "Rule 1" -> "Rule 2" -> "Rule 1"
@@ -94,6 +94,20 @@ var ruleTokens = { | |||
}; | |||
})(), | |||
|
|||
noLoop: (function () { | |||
var noLoopRegexp = /^(noLoop|no-loop)\s*:\s*(-?true|false)\s*[,;]?/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why '-?' in your regex ?
@@ -227,6 +227,8 @@ var Rule = declare({ | |||
this.name = name; | |||
this.pattern = pattern; | |||
this.cb = cb; | |||
this.noLoop = options.noLoop; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation 😄
@@ -37,6 +37,7 @@ Or [download the source](https://raw.github.com/C2FO/nools/master/nools.js) ([mi | |||
* [Structure](#rule-structure) | |||
* [Salience](#rule-salience) | |||
* [Scope](#rule-scope) | |||
* [no-loop](#rule-no-loop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation 😄
I made another PR to move forward |
Hi Doug, starting over on the pull requests with a cleaner history and a more factored aproach.