什么是`modified_timestamp`用于plotly store组件

问题描述 投票:0回答:1

我正在阅读关于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的原因。

plotly store plotly-dash
1个回答
1
投票

在您分享的文档页面中:

检索初始商店数据

如果使用数据prop作为输出,则无法使用数据prop获取初始数据。为了解决这个问题,您可以使用modified_timestamp作为输入,将数据用作State。

此限制是由于初始None回调阻塞了请求队列中的真实数据回调。

有关进一步的讨论,请参阅https://github.com/plotly/dash-renderer/pull/81

© www.soinside.com 2019 - 2024. All rights reserved.