Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use document_ready for onload callback #1562

Merged
merged 2 commits into from
Sep 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion panel/io/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pyviz_comms import CommManager as _CommManager
from tornado.web import decode_signed_value

from ..util import base64url_decode
from ..util import base64url_decode, bokeh_version


class _state(param.Parameterized):
Expand Down Expand Up @@ -126,6 +126,10 @@ def link(*events):
_updating[id(obj)] = not_updated
return link

def _on_load(self, event):
for cb in self._onload.pop(self.curdoc, []):
cb()

#----------------------------------------------------------------
# Public Methods
#----------------------------------------------------------------
Expand Down Expand Up @@ -209,6 +213,8 @@ def onload(self, callback):
return
if self.curdoc not in self._onload:
self._onload[self.curdoc] = []
if bokeh_version >= '2.2.0':
self.curdoc.on_event('document_ready', self._on_load)
self._onload[self.curdoc].append(callback)

def publish(self, endpoint, parameterized, parameters=None):
Expand Down