Skip to content

Fix the issue where Patch objects cannot be updated via set_props() in WebSocket callbacks#3759

Open
CNFeffery wants to merge 7 commits intoplotly:websocket-callbacksfrom
CNFeffery:websocket-callbacks
Open

Fix the issue where Patch objects cannot be updated via set_props() in WebSocket callbacks#3759
CNFeffery wants to merge 7 commits intoplotly:websocket-callbacksfrom
CNFeffery:websocket-callbacks

Conversation

@CNFeffery
Copy link
Copy Markdown
Contributor

The new websocket callback mechanism introduced starting from version 4.2.0rc1 currently does not allow updating Patch objects via set_props() within websocket-type callbacks. This PR fixes the aforementioned issue. Closes #3758

@CNFeffery
Copy link
Copy Markdown
Contributor Author

Based on the functional demonstration results of the local development version Dash, simulate the streaming content output effect similar to large language models:

demo

Core callback function code:

@app.callback(
    Input("load-stream-content", "nClicks"),
    websocket=True,
    running=[[Output("load-stream-content", "loading"), True, False]],
)
async def load_stream_content(nClicks):

    for s in test_markdown:
        await asyncio.sleep(0.02)

        p = Patch()
        p += s

        set_props("markdown-content", {"markdownStr": p})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant