Description Usage Arguments Value Examples
Merge two handler objects or add a handler in a handlers_list or dispatcher objects.
1 | add_handler(obj, .handler)
|
obj |
A handler, handler_list or dispatcher object. |
.handler |
A handler object. |
Retun a handlers_list
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | library(eventr)
library(magrittr)
birth_handler <- handler(type = 'BIRTH', FUN = function(obj, event){
obj$birth_date <- get_body_attr(event, 'birth_date')
return(obj)
})
measurement_handler <- handler(type = 'MEASUREMENT', FUN = function(obj, event){
obj$weight <- get_body_attr(event, 'weight')
obj$height <- get_body_attr(event, 'height')
return(obj)
})
death_handler <- handler(type = 'DEATH', FUN = function(obj, event){
obj$death_date <- get_body_attr(event, 'death_date')
return(obj)
})
handlers <- add_handler(birth_handler, death_handler)
handlers_01 <- birth_handler %>%
add_handler(measurement_handler) %>%
add_handler(death_handler)
handlers_02 <- birth_handler +
measurement_handler +
death_handler
identical(handlers_01, handlers_02)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.