- Notifications
You must be signed in to change notification settings - Fork2
'Golem' Hooks for Standard 'Shiny' Apps
License
Unknown, MIT licenses found
Licenses found
ThinkR-open/ghooks
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The goal of{ghooks}
is to provide{ghooks}
hooks for standard{shiny}
apps.
You can install the development version of{ghooks}
like so:
pak::pak("thinkr-open/ghooks")
You’re reading the doc about version : 0.0.0.9000
This README has been compiled on the
Sys.time()[1]"2023-03-27 13:07:03 CEST"
Here are the test & coverage results :
devtools::check(quiet=TRUE)ℹLoadingghooks──RCMDcheckresults ──────────────────────────────────ghooks0.0.0.9000 ────Duration:7.1s0errors ✔|0warnings ✔|0notes ✔
covr::package_coverage()ghooksCoverage:100.00%R/detect_ui_line.R:100.00%R/geyser_hook.R:100.00%
{golem}
hooks are functions that are called by{golem}
at specificmoments of the app lifecycle. They are used to add custom code to theapp, notably when creating the app withcreate_golem()
.
You can find more info about{golem}
hooks on{golem}
documentation.
The hooks can be called withgolem::create_golem(project_hook = )
,when creating a new golem project via the RStudio widget, as show on thescreenshot in theExtending{golem}
Vignette.
Below is the list of curently available hooks:
This hook is mainly intended at demoing the{golem}
hooks system. Itadds the “Old Faithful Geyser Data” app to your golem project.
Click here to see the content of `app_ui` and `app_server` from`geyser_hook`
pth<- tempfile(pattern="geyser")old_wd<- getwd()unlink(pth,recursive=TRUE)golem::create_golem(pth,project_hook=ghooks::geyser_hook,open=FALSE)──Checkingpackagename ───────────────────────────────────────────────────────✔Validpackagename──Creatingdir ────────────────────────────────────────────────────────────────✔Creating'/var/folders/9w/zdlv83ws6csdjnfc5x819gtr0000gn/T/RtmpMxqJJS/geyserd84144e998b8/'✔Settingactiveprojectto'/private/var/folders/9w/zdlv83ws6csdjnfc5x819gtr0000gn/T/RtmpMxqJJS/geyserd84144e998b8'✔Creating'R/'✔Writingasentinelfile'.here'•Buildrobustpathswithinyourprojectvia`here::here()`•Learnmoreat<https://here.r-lib.org>✔Settingactiveprojectto'<no active project>'✔Createdpackagedirectory──Copyingpackageskeleton ────────────────────────────────────────────────────✔Copiedappskeleton──Runningprojecthookfunction ───────────────────────────────────────────────Styling1files:R/app_ui.R ℹ ────────────────────────────────────────StatusCountLegend ✔0Fileunchanged.ℹ1Filechanged.✖0Stylingthrewanerror.────────────────────────────────────────Pleasereviewthechangescarefully!Styling1files:R/app_server.R ℹ ────────────────────────────────────────StatusCountLegend ✔0Fileunchanged.ℹ1Filechanged.✖0Stylingthrewanerror.────────────────────────────────────────Pleasereviewthechangescarefully!✔Allset✔Settingactiveprojectto'/private/var/folders/9w/zdlv83ws6csdjnfc5x819gtr0000gn/T/RtmpMxqJJS/geyserd84144e998b8'──Done ────────────────────────────────────────────────────────────────────────Anewgolemnamedgeyserd84144e998b8wascreatedat/var/folders/9w/zdlv83ws6csdjnfc5x819gtr0000gn/T//RtmpMxqJJS/geyserd84144e998b8.Tocontinueworkingonyourapp,starteditingthe01_start.Rfile.
cat( readLines( file.path(pth,"R","app_ui.R") ),sep="\n")#' The application User-Interface#'#' @param request Internal parameter for `{shiny}`.#' DO NOT REMOVE.#' @import shiny#' @noRdapp_ui<-function(request) { tagList(# Leave this function for adding external resources golem_add_external_resources(),# Your application UI logic fluidPage(# Application title titlePanel("Old Faithful Geyser Data"),# Sidebar with a slider input for number of bins sidebarLayout( sidebarPanel( sliderInput("bins","Number of bins:",min=1,max=50,value=30 ) ),# Show a plot of the generated distribution mainPanel( plotOutput("distPlot") ) ) ) )}#' Add external Resources to the Application#'#' This function is internally used to add external#' resources inside the Shiny application.#'#' @import shiny#' @importFrom golem add_resource_path activate_js favicon bundle_resources#' @noRdgolem_add_external_resources<-function() { add_resource_path("www", app_sys("app/www") )tags$head( favicon(), bundle_resources(path= app_sys("app/www"),app_title="geyserd84144e998b8" )# Add here other external resources# for example, you can add shinyalert::useShinyalert() )}
cat( readLines( file.path(pth,"R","app_server.R") ),sep="\n")#' The application server-side#'#' @param input,output,session Internal parameters for {shiny}.#' DO NOT REMOVE.#' @import shiny#' @noRdapp_server<-function(input,output,session) {# Your application server logicoutput$distPlot<- renderPlot({# generate bins based on input$bins from ui.Rx<-faithful[,2]bins<- seq(min(x), max(x),length.out=input$bins+1)# draw the histogram with the specified number of bins hist(x,breaks=bins,col="darkgray",border="white") })}
You’re reading the doc about version : 0.0.0.9000
This README has been compiled on:
Sys.time()[1]"2023-03-27 13:07:14 CEST"
Here are the test & coverage results :
devtools::check(quiet=TRUE)ℹLoadingghooks──RCMDcheckresults ──────────────────────────────────ghooks0.0.0.9000 ────Duration:7.6s0errors ✔|0warnings ✔|0notes ✔
covr::package_coverage()ghooksCoverage:100.00%R/detect_ui_line.R:100.00%R/geyser_hook.R:100.00%
About
'Golem' Hooks for Standard 'Shiny' Apps