https://github.com/genentech/battery
Architecture framework for Shiny Apps
https://github.com/genentech/battery
architecture component-architecture rstats shiny shiny-apps
Last synced: about 1 year ago
JSON representation
Architecture framework for Shiny Apps
- Host: GitHub
- URL: https://github.com/genentech/battery
- Owner: Genentech
- License: mit
- Created: 2022-08-19T18:40:51.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-23T08:41:13.000Z (almost 4 years ago)
- Last Synced: 2024-05-01T18:57:29.491Z (about 2 years ago)
- Topics: architecture, component-architecture, rstats, shiny, shiny-apps
- Language: R
- Homepage:
- Size: 259 KB
- Stars: 4
- Watchers: 5
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[R6Class based component architecture framework for Shiny apps](https://github.com/Genentech/battery)
The components design is based on AngularJS that can emit event from root it it's children
and broadcast events from child to parents. It give better structure of non trivial shiny apps,
that need to have lots of different parts.
## Installation
```sh
git clone https://github.com/Genentech/battery.git
R CMD INSTALL battery
```
## Basic usage
```R
Button <- battery::component(
classname = "Button",
label = NULL,
constructor = function(label = NULL) {
self$label = label
},
render = function() {
shiny::tags$button(self$label)
}
)
App <- battery::component(
classname = "App",
public = list(
constructor = function() {
btn <- Button$new(label = "Click me", parent = self, component.name = "button")
self$output[[ self$ns("root") ]] <- shiny::renderUI({
shiny::tags$div(
shiny::tags$p("click the button"),
btn$render()
)
})
},
render = function() {
tags$div(
titlePanel('Shiny App using Battery R package'),
mainPanel(shiny::uiOutput(self$ns("root")))
)
}
)
)
```
## Documentation
For full documentation see [Battery Components](vignettes/battery-components.Rmd) Vignette.
You can also read tutorial about the framework features at DEV.to:
[Architecture for Non-Trivial R Shiny Applications](https://dev.to/jcubic/architecture-for-non-trivial-r-shiny-applications-3816)
## Contributors
* [Jakub T. Jankiewicz](https://github.com/jcubic) - main author
* Michał Jakubczak
## License
Copyright (c) 2019-2021 Genentech, Inc.
Released under MIT license