Using long and pattern-matching callback

I have to use a long callback function that does heavy computation. Meanwhile, I also need its output dynamic conditioned on an store value. Here is the example of what I want:

@app.long_callback(
           Output({"name": "div-content", "index": ALL}),
           Input("user-input", "value"),
           State("n-content", "data")
           )
def process(user_input, n_content):
       time.sleep(1e6)
       return ["hello"+user_input for _ in range(n_content)]

Is there any way to do so? If not, I wonder if there is a way to disable the button when executing the callback function?

According to Long Callbacks documentation, long callbacks currently do NOT support pattern-matching dependencies.

There’s an open GitHub issue on this topic (a feature request). You can support it by adding a comment or like…

Also there’s one workaround suggested here on the forum but I never tried it myself.

1 Like