{
Elements: {
Events: {
_: TK.Event,
Subscribe: ["Test"], // Subscribe for event type Test
Receive: function(eventType, eventData) {
this.Parent.Elements.ReceivedEvents.Add({
_: "p", innerText: eventData
});
}
},
ReceivedEvents: {
innerHTML: "Events received will be displayed here"
}
}
}
{
_: "button",
innerHTML: "Press me and look at the example output above",
onclick: function() {
TK.Event.Send("Test", "This is the data")
}
}
An useful extension on the TK.Event for handling events using event types mapped to function names.
{
HandleTest: function(eventData) {
this.Elements.ReceivedEvents.Add({
_: "p", innerText: eventData
});
},
Elements: {
Events: {
_: TK.MappedEvent
},
ReceivedEvents: {
innerHTML: "Events received will be displayed here"
}
}
}