Explicit events are raised in the rule postlude with a raise statement. You can raise events from a postlude like so:
Code Block | ||||
---|---|---|---|---|
| ||||
raise <domain> event <expr> [for <expr>] [attributes <expr>] |
...
Warning |
---|
Because the event name is an expression, you must use a string rather than using a bare word. |
Info |
---|
If you want to raise an event on a schedule, please refer to the schedule documentation. |
Attributes Clause
The attributes
clause allows the developer to add event attributes to the event. The expression that follows the attributes
key word must evaluate to a map. The keys and values in the map will be used as event attributes. This is particularly useful when you want to pass through all, or most, of the attributes that the current rule received:
Code Block | ||||
---|---|---|---|---|
| ||||
raise some_domain event "foo" attributes event:attrs |
...
In the Sky Event API, explicit events will be raised to any ruleset that an entity has installed unless a for
clause is present. You can specify the current ruleset using meta:rid
from the meta library.
Like any other postlude statement, explicit events can be guarded:
Code Block | ||||
---|---|---|---|---|
| ||||
raise explicit event "foo" attributes { "a" : "hello", "b" : 4 + x } if (flipper == "two"); |
...