You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ Lets see how a sample rule will look like and then proceed to explain the differ
38
38
39
39
Above is a sample rule which has mandatory as well as optional parameters. You can choose to use which all attributes you need to use while defining your rule. Now let look into the attributes one by one.
40
40
41
-
##### A. condition
41
+
##### 1.1. condition
42
42
Condition is a function where the user can do the checks on the fact provided. The fact varaiable will be available in `this` context of the condition function. Lets see a sample condition below.
43
43
44
44
"condition": function(R) {
@@ -49,7 +49,7 @@ As you can see, the we have to pass an expression on to the `R.when` API. If the
49
49
50
50
Its mandatory to have this field.
51
51
52
-
##### B. consequnce
52
+
##### 1.2. consequnce
53
53
The consequence is the part where the we define what happens when the condition evaluates to true for a particular fact. Just like in condition, fact varaiable will be available in `this` context. You may utilize it to add extra result attributes if needed.
54
54
55
55
"consequence": function(R) {
@@ -60,17 +60,17 @@ In the above example we use an additional parameter `result` to communicate to t
60
60
61
61
Its mandatory to have this field.
62
62
63
-
##### C. priority
63
+
##### 1.3. priority
64
64
This field is used to specify the priority of a rule. The rules with higher priority will be applied on the fact first and then followed by lower priority rules. You can have multiple rules with same priority and the engine will not ensure the order in that case.
65
65
66
66
Its not mandatory to have this field.
67
67
68
-
##### D. on
68
+
##### 1.4. on
69
69
This is field is used to store the state of a rule. This is used to activate and diactivate rules at run time. Rules with `on` set to `false` will not be applied on the facts.
70
70
71
71
It is not mandatory to have this field.
72
72
73
-
##### E. add a unique attribute
73
+
##### 1.5. add a unique attribute
74
74
It is suggested that you should add a property which can be used as a unique identifier for a rule. Why it is because when you need to dynamically turn on/off or change priority of a rule, you will need a filter to select a rule from the engine via the APIs. That time you may use the unique property as a key for the filter for selection process.
75
75
76
76
Suppose that in the above example `name` is unique for each rule. Then for changing state or re prioritizing a rule at run time, you may use a filter like `{"name":"transaction minimum"}`.
0 commit comments