2

I have users calling functions while typing. The problem is that it makes the call for every letter being typed and error is shown if textbox is empty even for 1ms.

Warning: Error in twInterfaceObj$doAPICall: Forbidden (HTTP 403).

How can I change this to make the function call only after about 400ms after the last typed letter?

Here is my Shiny code:

ui.R

shinyUI(fluidPage(
    # Sidebar with a slider input for number of bins 
    sidebarLayout(
        sidebarPanel(
            textInput("new_hashtag", label = h4("Enter #Hashtag"), value = "#hello")
        )
    ),
    mainPanel(
        DT::dataTableOutput('mytable1')
    )
))

server.R

shinyServer(function(input, output, session) {
    output$mytable1 <- DT::renderDataTable({
        df <- searchTwitter(as.character(input$new_hashtag)
        DT::datatable(twListToDF(df))
    })        
})
Lok
  • 129
  • 1
  • 2
  • 13
  • 1
    You have 2 different options: 1) Force user to click a submit button, 2) Update JavaScript to listen for an Enter or pause between keystrokes. The second option is a better user experience, but you'll need some extra knowledge of JavaScript. – Steven M. Mortimer Jun 19 '17 at 15:49
  • Yes this can be one option, but I am also looking for something in R which can help me in this. – Lok Jun 19 '17 at 16:14
  • Refer to [this](https://stackoverflow.com/a/38960525/5894457). `Debounce` might just be what you are looking for. – SBista Jun 23 '17 at 07:18

0 Answers0