Event emitter is inspired by multiple implementation in JavaScript
Source:R/EventEmitter.R
EventEmitter.Rdit can be used indepentely of battery events to send data from one component to different one, without the need to broadcast and emit events it can be used with services, in addition to can also be used as reactive values in shiny reactive context like renderUI or battery component render function
Methods
- Documentation
For full documentation of each method go to https://stash.intranet.roche.com/stash/projects/DIVOS/repos/battery/browse
EventEmitter$new(...)This method is used to create EventEmitter
onMethod add new handler for given event
emitMethod emit event add trigger all handlers added by
onoffMethod removes single handler or all handlers and observer of no handler left
finalizeDestructor - clean up the data
Public fields
.calls- if EventEmitter is created with
spy = TRUEit will add method calls to this listevents- environment with reactive objects if EventEmitter created wtih
shiny = TRUE, otherwise it's normal environment but with R active bindings that can't be used in shiny render functions
Methods
Method new()
R6Class destructor. Cleans up event handlers
R6Class Constructor. If shiny option is used it will create ReactiveBinding
with hack that always trigger reactive context (the same cases the
component events - this is shiny bug)
Usage
EventEmitter$new(spy = FALSE, shiny = FALSE)Method on()
Method add new handler for given event
create new observer if doesn't exists and add handler to the list to that observer, we use single observer so ... will be of no use on next handler on single event, we keep it just in case it may be of use