Skip to content

Commit 6c4f596

Browse files
committed
Add bookmark workaround for on_restored() callbacks not executing on load #1889
1 parent 27b88b5 commit 6c4f596

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

shiny/bookmark/_bookmark.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,7 @@ async def invoke_on_restore_callbacks():
363363

364364
# Run the on_restored function after the flush cycle completes and
365365
# information is sent to the client.
366-
# Update: Using `on_flush` to have the callbacks populate the output message
367-
# queue going to the browser. If `on_flushed` is used, the messages stall
368-
# until the next `on_flushed` invocation.
369-
@session.on_flush
366+
@session.on_flushed
370367
async def invoke_on_restored_callbacks():
371368
if self._on_restored_callbacks.count() == 0:
372369
return

shiny/session/_session.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,11 @@ def verify_state(expected_state: ConnectionState) -> None:
664664
with session_context(self):
665665
self.app.server(self.input, self.output, self)
666666

667+
# TODO: Remove this call to reactive_flush() once https://github.com/posit-dev/py-shiny/issues/1889 is fixed
668+
# Workaround: Any `on_flushed()` calls from bookmark's `on_restored()` will be flushed here
669+
if self.bookmark.store != "disable":
670+
await reactive_flush()
671+
667672
elif message_obj["method"] == "update":
668673
verify_state(ConnectionState.Running)
669674

0 commit comments

Comments
 (0)