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

checkin for rule attribute no-loop #181

Closed
wants to merge 1 commit into from

Conversation

markbjerke
Copy link

Hi Doug, starting over on the pull requests with a cleaner history and a more factored aproach.

Copy link
Collaborator

@DevSide DevSide left a 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*[,;]?/;
Copy link
Collaborator

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;
Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation 😄

@DevSide DevSide mentioned this pull request Nov 6, 2016
@DevSide
Copy link
Collaborator

DevSide commented Nov 6, 2016

I made another PR to move forward

@DevSide DevSide closed this Nov 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants