create_handler_registration: Create a New Handler Registration

Description Usage Examples

Description

Create a new handler registration. Objects generated from this function implement the interface described in events – handlers can be attached and detached with on / off. and events can be emitted with emit.

Usage

1

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# create a handler registration
registration <- create_handler_registration()

# attach a handler
id <- registration$on("hello", function(data) {
  print(paste("Hello,", data))
}, scoped = FALSE)

# emit an event -- see 'Hello, world' printed to console
registration$emit("hello", "World")

# detach event
registration$off("hello", id)

# emit event again -- nothing printed as no active handler present
registration$emit("hello", "World")

kevinushey/later documentation built on May 20, 2019, 9:09 a.m.