-
Notifications
You must be signed in to change notification settings - Fork 1
/
usage.py
43 lines (32 loc) · 1.05 KB
/
usage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import json
import dash_lazy_load
import dash.dependencies
import dash_html_components as html
app = dash.Dash('')
app.scripts.config.serve_locally = True
app.layout = html.Div([
html.Div('Testing', style=dict(height=1200)),
dash_lazy_load.LazyLoad(
html.Div('I loaded in lazily!!', style=dict(border='5px solid blue')),
height=500,
debounce=1000),
dash_lazy_load.Debouncer(id='debouncer', debounce=2000, sendTrueValue=False),
html.Button('A button!', id='my-button'),
html.Div('', id='my-output'),
])
@app.callback(
output=dash.dependencies.Output('my-output', 'children'),
inputs=[
dash.dependencies.Input('debouncer', 'debouncedVals'),
])
def update_debounced(debouncedVals):
return json.dumps(debouncedVals)
@app.callback(
output=dash.dependencies.Output('debouncer', 'inputVals'),
inputs=[
dash.dependencies.Input('my-button', 'n_clicks'),
])
def button_debounced(n_clicks):
return {'button_clicks': n_clicks}
if __name__ == '__main__':
app.run_server(debug=True)