Date: Fri, 29 Mar 2024 07:23:29 +0000 (UTC) Message-ID: <472718126.803.1711697009709@51553893d29e> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_802_906799994.1711697009709" ------=_Part_802_906799994.1711697009709 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Explicit events are raised in the rule postlude with a raise sta= tement. You can raise events from a postlude like so:
raise <= ;domain> event <expr> [for <expr>] [attributes <expr>]=
The event name is given by the <expr>
. The expre=
ssion is evaluated and the resulting string is used as the event name.
Because the event name is an expression, you must use a string rather th= an using a bare word.
If you want to raise an event on a schedule, please refer to the schedule documentation.
The attributes
clause allows the developer to add event att=
ributes to the event. The expression that follows the attributes=
key word must evaluate to a map. The keys and values in the ma=
p will be used as event attributes. This is particularly useful when you wa=
nt to pass through all, or most, of the attributes that the current rule re=
ceived:
raise som= e_domain event "foo" attributes event:attrs
This raises the event some_domain:foo
with all of the attri=
butes that were passed into the enclosing rule.
You can control which rulesets see an explicit event using the optional&=
nbsp;for
clause.
The for clause is followed by an expression that is evaluated to determi= ne which rule sets should see the event. The result must be a string, givin= g the target ruleset ID or an array of target rulesets. At the moment, the = system will use the version of the current ruleset.
In the Sky Event API, explicit events will be raised =
to any ruleset that an entity has installed unless a for
claus=
e 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:
raise exp= licit event "foo" attributes { "a" : "hello", "b" : 4 + x } if (flipper =3D=3D "two");
The event in the preceding example will only be raised if the variable f= lipper has the value "two".
Explicit events allow KRL programmers to chain rules together. Rule chai= ning is good for modularization, error handling, preprocessing, and abstrac= tion.