Create a new handler registration. Objects generated from this function
implement the interface described in events
– handlers can
be attached and detached with on
/ off
. and events can be
emitted with emit
.
1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # create a handler registration
registration <- create_handler_registration()
# attach a handler
id <- registration$on("hello", function(data) {
print(paste("Hello,", data))
}, scoped = FALSE)
# emit an event -- see 'Hello, world' printed to console
registration$emit("hello", "World")
# detach event
registration$off("hello", id)
# emit event again -- nothing printed as no active handler present
registration$emit("hello", "World")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.