Skip to content

checkin for rule attribute no-loop#181

Closed
markbjerke wants to merge 1 commit into
noolsjs:masterfrom
markbjerke:no-loop-rc
Closed

checkin for rule attribute no-loop#181
markbjerke wants to merge 1 commit into
noolsjs:masterfrom
markbjerke:no-loop-rc

Conversation

@markbjerke
Copy link
Copy Markdown

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

Copy link
Copy Markdown
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"

})(),

noLoop: (function () {
var noLoopRegexp = /^(noLoop|no-loop)\s*:\s*(-?true|false)\s*[,;]?/;
Copy link
Copy Markdown
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 ?

Comment thread lib/rule.js
this.name = name;
this.pattern = pattern;
this.cb = cb;
this.noLoop = options.noLoop;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

indentation 😄

Comment thread readme.md
* [Structure](#rule-structure)
* [Salience](#rule-salience)
* [Scope](#rule-scope)
* [no-loop](#rule-no-loop)
Copy link
Copy Markdown
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
Copy Markdown
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