Learn R Programming

dash (version 0.9.4)

prevent_update: Prevent a callback from updating its output

Description

When used inside Dash callbacks, if any of the arguments evaluate to TRUE, then the callback's outputs do not update.

Usage

prevent_update(...)

Arguments

...

Values to check

Examples

Run this code
# NOT RUN {
if (interactive()) {
    app <- dash_app()

    app %>% set_layout(
      button('Click here', id = 'btn'),
      p('The number of times the button was clicked does not
       update when the number is divisible by 5'),
      div(id = 'body-div')
    )
    app %>% add_callback(
      output(id='body-div', property='children'),
      list(
        input(id='btn', property='n_clicks')
      ),
      function(n_clicks) {
        prevent_update(is.null(n_clicks[[1]]), n_clicks[[1]] %% 5 == 0)
        paste(n_clicks[[1]], "clicks")
      }
    )

    app %>% run_app()
}
# }

Run the code above in your browser using DataLab