# 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