Constructor
new RuleEngine(optionsOrFactsopt, maybeBusopt, maybeOptionsopt)
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
optionsOrFacts | WorldFacts | | <optional> | ||
maybeBus | TypedEventBus | <optional> | null | |
maybeOptions | object | <optional> |
- Source
Classes
Members
ruleCount
Total number of registered rules.
- Source
Methods
addRule(ruleDef) → {function}
Adds an ordered condition/effect rule.
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ruleDef | object | Properties
|
- Source
Unbind function
- Type:
- function
clearDecisionTraces()
Clears all recorded decision traces.
- Source
clearRules()
Unbinds and clears all registered rules.
- Source
disableRule(ruleId)
Disables a rule.
| Name | Type | Description |
|---|---|---|
ruleId | string |
- Source
dispose()
Cleans up all rules and decision traces.
- Source
enableRule(ruleId)
Enables a rule.
| Name | Type | Description |
|---|---|---|
ruleId | string |
- Source
evaluate(eventTypeopt, eventDataopt, optionsopt) → {Object}
Evaluates matching rules in priority order against facts and event data.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
eventType | string | | <optional> | null | |
eventData | any | <optional> | {} | |
options | object | <optional> |
- Source
- Type:
- Object
getDecisionTraces(filteropt) → {Array.<object>}
Retrieves recorded decision traces with optional filtering.
| Name | Type | Attributes | Description |
|---|---|---|---|
filter | object | <optional> |
- Source
- Type:
- Array.<object>
getLastDecisionTrace() → {object|null}
Returns the most recent decision trace.
- Source
- Type:
- object |
null
getRule(ruleId) → {object|null}
Returns a rule definition by ID.
| Name | Type | Description |
|---|---|---|
ruleId | string |
- Source
- Type:
- object |
null
hasRule(ruleId) → {boolean}
Checks if a rule is registered.
| Name | Type | Description |
|---|---|---|
ruleId | string |
- Source
- Type:
- boolean
removeRule(ruleId) → {boolean}
Removes a rule and cleans up all its event bus subscriptions.
| Name | Type | Description |
|---|---|---|
ruleId | string |
- Source
- Type:
- boolean