Tip:
Highlight text to annotate it
X
Let's talk about explicit events. No! Not what you did at that party last Saturday,
but explicit event is KRL. In KRL you have the ability to react to specific events in
the browser like page views, click. Now we have the ability to raise our own events and
react to those events. We can also pass data associated with those events. So in this example
app running on example.com, I'll show one rule that reacts to a page view and raises
an explicit event. Then I'll have another rule that reacts to that event and shows the
passed data in a notify. So here in the raise event rule we are selecting on any page view,
and on any page view we'll run a noop action. Once that has fired we'll raise the explicit
event named 'mustafa' with two variables. One named 'expression' with the value of 'Will
using Old Spice make me smell manlier?' and a variable named result with the value of
'Yes' wrapped in HTML tags. Now our second rule will react to this mustafa event. This
rule is named 'react'. We are selecting when explicit mustafa. Now the name of the explicit
event can be anything you like, just like with your variables. So, the way we get the
passed data with the event is in the pre block using the syntax
'event:param("[variable name]");
So, now we are grabbing the expression variable and the result variable associated with the
mustafa event that was raised. Then I simply take those saved values and show them in a
notify. So let's go to our browser and run the application and we'll see a notification
with the answer of 'Will using Old Spice make me smell manlier?'. There you have explicit
events in KRL.