Description Usage Arguments Value Examples
Construct a handler object.
1 2 3 4 5 | handler(type, FUN)
new_handler(type, FUN)
validate_handler(type, FUN)
|
type |
A character string indicating the event type to handle. |
FUN |
A function which use an obj and an event as input parameters and returns an object as output. |
The handler()
function returns an object of type handler
. A handler
object
contains two elements: type
and FUN
. Type is a string indicating the type of event and FUN
is a R
function with to params: obj
and event
. obj
is any R object and
event
is an event
object returned by the event()
function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | set_birth_date <- function(obj, event){
obj$birthDate <- event$body$birthDate
return(obj)
}
set_death_date <- function(obj, event){
obj$deathDate <- event$body$deathDate
return(obj)
}
birth_handler <- handler(type = 'BIRTH', FUN = set_birth_date)
birth_handler
death_handler <- handler(type = 'DEATH', FUN = set_death_date)
death_handler
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.