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: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
#### 6.0. / 2020-12-XX
2
+
* BREAKING CHANGES
3
+
* Private `rule.event` property renamed. Use `rule.getEvent()` to avoid breaking changes in the future.
4
+
* Engine and Rule events `on('success')`, `on('failure')`, and Rule callbacks `onSuccess` and `onFailure` now honor returned promises; any event handler that returns a promise will be waited upon to resolve before engine execution continues.
Fires when a rule passes. The callback will receive the event object, the current [Almanac](./almanac.md), and the [Rule Result](./rules.md#rule-results).
179
+
Fires when a rule passes. The callback will receive the event object, the current [Almanac](./almanac.md), and the [Rule Result](./rules.md#rule-results). Any promise returned by the callback will be waited on to resolve before execution continues.
Companion to 'success', except fires when a rule fails. The callback will receive the event object, the current [Almanac](./almanac.md), and the [Rule Result](./rules.md#rule-results).
189
+
Companion to 'success', except fires when a rule fails. The callback will receive the event object, the current [Almanac](./almanac.md), and the [Rule Result](./rules.md#rule-results). Any promise returned by the callback will be waited on to resolve before execution continues.
Copy file name to clipboardExpand all lines: docs/rules.md
+15-3Lines changed: 15 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,24 +50,36 @@ let rule = new Rule(options)
50
50
51
51
**options.priority** : `[Number, default 1]` Dictates when rule should be run, relative to other rules. Higher priority rules are run before lower priority rules. Rules with the same priority are run in parallel. Priority must be a positive, non-zero integer.
52
52
53
-
**options.onSuccess** : `[Function(Object event, Almanac almanac)]` Registers callback with the rule's `on('success')` listener. The rule's `event` property and the current [Almanac](./almanac.md) are passed as arguments.
53
+
**options.onSuccess** : `[Function(Object event, Almanac almanac)]` Registers callback with the rule's `on('success')` listener. The rule's `event` property and the current [Almanac](./almanac.md) are passed as arguments. Any promise returned by the callback will be waited on to resolve before execution continues.
54
54
55
-
**options.onFailure** : `[Function(Object event, Almanac almanac)]` Registers callback with the rule's `on('failure')` listener. The rule's `event` property and the current [Almanac](./almanac.md) are passed as arguments.
55
+
**options.onFailure** : `[Function(Object event, Almanac almanac)]` Registers callback with the rule's `on('failure')` listener. The rule's `event` property and the current [Almanac](./almanac.md) are passed as arguments. Any promise returned by the callback will be waited on to resolve before execution continues.
56
56
57
57
**options.name** : `[Any]` A way of naming your rules, allowing them to be easily identifiable in [Rule Results](#rule-results). This is usually of type `String`, but could also be `Object`, `Array`, or `Number`. Note that the name need not be unique, and that it has no impact on execution of the rule.
58
58
59
59
### setConditions(Array conditions)
60
60
61
61
Helper for setting rule conditions. Alternative to passing the `conditions` option to the rule constructor.
62
62
63
+
### getConditions() -> Object
64
+
65
+
Retrieves rule condition set by constructor or `setCondition()`
66
+
63
67
### setEvent(Object event)
64
68
65
69
Helper for setting rule event. Alternative to passing the `event` option to the rule constructor.
66
70
71
+
### getEvent() -> Object
72
+
73
+
Retrieves rule event set by constructor or `setEvent()`
74
+
67
75
### setPriority(Integer priority = 1)
68
76
69
77
Helper for setting rule priority. Alternative to passing the `priority` option to the rule constructor.
70
78
79
+
### getPriority() -> Integer
80
+
81
+
Retrieves rule priority set by constructor or `setPriority()`
82
+
71
83
### toJSON(Boolean stringify = true)
72
84
73
85
Serializes the rule into a JSON string. Often used when persisting rules.
@@ -207,7 +219,7 @@ For an example, see [fact-dependency](../examples/04-fact-dependency.js)
207
219
208
220
### Comparing facts
209
221
210
-
Sometimes it is necessary to compare facts against others facts. This can be accomplished by nesting the second fact within the `value` property. This second fact has access to the same `params` and `path` helpers as the primary fact.
222
+
Sometimes it is necessary to compare facts against other facts. This can be accomplished by nesting the second fact within the `value` property. This second fact has access to the same `params` and `path` helpers as the primary fact.
211
223
212
224
```js
213
225
// identifies whether the current widget price is above a maximum
0 commit comments