prevent_update: Prevent a callback from updating its output

View source: R/callbacks-advanced.R

prevent_updateR Documentation

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

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()


daattali/dash2 documentation built on July 1, 2023, 9:28 a.m.