handler: Handler Constructor

Description Usage Arguments Value Examples

View source: R/handler.R

Description

Construct a handler object.

Usage

1
2
3
4
5

Arguments

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.

Value

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.

Examples

 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

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