Kaynağa Gözat

Refactor into resetTypingSpeed()

shiny-input
Garrick Aden-Buie 6 yıl önce
ebeveyn
işleme
644a8b6c2e
2 değiştirilmiş dosya ile 11 ekleme ve 1 silme
  1. +5
    -1
      inst/shiny-input-app/app.R
  2. +6
    -0
      inst/shiny-input-app/dev-shiny-input.Rmd

+ 5
- 1
inst/shiny-input-app/app.R Dosyayı Görüntüle

@@ -20,6 +20,10 @@ typingSpeedInput <- function(inputId, label, placeholder = NULL) {
)
}

resetTypingSpeed <- function(inputId, session = getDefaultReactiveDomain()) {
session$sendInputMessage("typing", TRUE)
}

ui <- fluidPage(
# textAreaInput("typing", "Type here..."),
typingSpeedInput("typing", "Type here..."),
@@ -31,7 +35,7 @@ server <- function(input, output, session) {
output$debug <- renderPrint(input$typing)

observeEvent(input$reset, {
session$sendInputMessage("typing", TRUE)
resetTypingSpeed("typing")
})
}


+ 6
- 0
inst/shiny-input-app/dev-shiny-input.Rmd Dosyayı Görüntüle

@@ -473,3 +473,9 @@ to send `typing` a `TRUE`
whenever the button is clicked.

`r github_sha_link("269e4ebdc48a66ecf7466192076c4fa259582cc6")`

Once you get that working,
refactor it into a `resetTypingSpeed()` function.

This function should take an `inputId` and a `session` object.
Use `shiny::getDefaultReactiveDomain()` for the default `session` value.

Yükleniyor…
İptal
Kaydet