Skip to contents

Components

Building the tree of components. Every component is created with component() and inherits the methods documented in BaseComponent.

component()
Basic function to create battery components.
BaseComponent
Root component that have no parent,

Events

Event emitters that can be used as services shared by the whole tree.

EventEmitter
Event emitter is inspired by multiple implementation in JavaScript

Exceptions

Signals and errors raised anywhere in the component tree are handled in one place, see the vignette("battery-components") for the whole picture.

exceptions()
function allows to add global exception handler for all battery components
withExceptions()
global exception handler that is used in battery instead of tryCatch
signal()
signal exception in applications
error()
helper function that can be used in exception handler to trigger error handler
create.error()
create structure that can be used to signal error in applications
pause()
helper function that can be used in exception handler to pause just this context
end()
helper function that can be used in exception handler to stop whole application
capture_signal_messages()
helper function that capture all signal messages into a vector it can be used in unit tests to check if the function sent proper messages

Testing

Mocks that replace the shiny reactive machinery so components can be tested without a running shiny session.

Session
Shiny Session Mock class
useMocks()
Helper function to be used in test files that overwrite shiny functions (after test you should run clearMocks since they are global and if you run shiny application after test that use mocks it will break)
clearMocks()
Helper function to be used at the end of test files (useful if same session is used to run test and application e.g. RStudio)
activeInput()
Function create mock for shiny input
activeOutput()
Function create active binding output mock to be used with renderUI mock
renderUIMock()
RenderUI just send exression to output active prop, the prop need to be added first if renderUI is called in constructor and it use self$ns() you can pass component.id to constructor so instance will have same id and you can generate the name before constructor is called - using: output$new(name) the output will parse the expression and bind input and output note: input can have different name for instance events in components
makeReactiveBinding()
Mock for shiny::makeReactiveBinding to be injected into components limiation it can't be called after value is added to environment (it will work in components)
isolate()
name used only inside renderUI in substitute phase
is.active.binding()
Function check if name is active biding inside environment activeInput or activeOutput
is.active.input()
Function for checking if object is actie input - used by extractActiveInputs
is.active.output()
Function check if obj is enviroment that is result of activeOutput function

Utilities

load()
Function load all R file components from directory, component classes will be global
%>%
Pipe operator
is
is generic function