`modified_timestamp` 在 plotly store 组件中的用途是什么
what is `modified_timestamp` used for in plotly store component
我正在阅读 https://dash.plot.ly/dash-core-components/store
上的第一个示例
为什么
@app.callback(Output('{}-clicks'.format(store), 'children'),
[Input(store, 'modified_timestamp')],
[State(store, 'data')])
def on_data(ts, data):
if ts is None:
raise PreventUpdate
data = data or {}
return data.get('clicks', 0)
而不是
@app.callback(Output('{}-clicks'.format(store), 'children'),
[Input(store, 'data')])
def on_data(data):
data = data or {}
return data.get('clicks', 0)
我不明白为什么要使用 modified_timestamp
。
来自您共享的文档页面:
Retrieving the initial store data
If you use the data prop as an output, you cannot get the initial data on load with the data prop. To counter this, you can use the modified_timestamp
as Input and the data as State.
This limitation is due to the initial None callbacks blocking the true data callback in the request queue.
See https://github.com/plotly/dash-renderer/pull/81 for further discussion.
我正在阅读 https://dash.plot.ly/dash-core-components/store
上的第一个示例为什么
@app.callback(Output('{}-clicks'.format(store), 'children'),
[Input(store, 'modified_timestamp')],
[State(store, 'data')])
def on_data(ts, data):
if ts is None:
raise PreventUpdate
data = data or {}
return data.get('clicks', 0)
而不是
@app.callback(Output('{}-clicks'.format(store), 'children'),
[Input(store, 'data')])
def on_data(data):
data = data or {}
return data.get('clicks', 0)
我不明白为什么要使用 modified_timestamp
。
来自您共享的文档页面:
Retrieving the initial store data
If you use the data prop as an output, you cannot get the initial data on load with the data prop. To counter this, you can use the
modified_timestamp
as Input and the data as State.This limitation is due to the initial None callbacks blocking the true data callback in the request queue.
See https://github.com/plotly/dash-renderer/pull/81 for further discussion.