handler-add: Add handlers to a handlers_list

Description Usage Arguments Value Examples

Description

Merge two handler objects or add a handler in a handlers_list or dispatcher objects.

Usage

1
2
## S3 method for class 'handler'
e1 + e2

Arguments

e1

A handler, handler_list or dispatcher object.

e2

A handler or handlers_list object.

Value

Retun a handlers_list object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 <- birth_handler +
  measurement_handler +
  death_handler

eventr documentation built on July 8, 2020, 7:32 p.m.