Dash Events trigger callback function Twice in every single event, or “last call will be repeated” in a very short time period. The problem is that further function within callback will be triggered twice.
####################################
import dash
import dash_core_components as dcc
import dash_html_components as html
import datetime
app = dash.Dash()
app.layout = html.Div([
dcc.Interval(id='my-interval', interval=1000*5, n_intervals=0),
html.Div(id='display-time'),
])
@app.callback(
output=dash.dependencies.Output('display-time', 'children'),
inputs=[dash.dependencies.Input('my-interval', 'n_intervals')],
events=[dash.dependencies.Event('my-interval', 'interval')])
def display_time(n):
print ('n_intervals:' + str(n) + ' at ' + str(datetime.datetime.now()))
# further_function_which_should_be_controlled_by_dcc.Interval()
return "Call No.: {}; Call at: {}".format(n, str(datetime.datetime.now()))
if __name__ == '__main__':
app.run_server(debug=True)