
Last chance! 50% off unlimited learning
Sale ends in
Construct a handler object.
handler(type, FUN)new_handler(type, FUN)
validate_handler(type, FUN)
A character string indicating the event type to handle.
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.
# NOT RUN {
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
# }
Run the code above in your browser using DataLab