Skip to content

Commit

Permalink
Use document_ready for onload callback (#1562)
Browse files Browse the repository at this point in the history
* Use document_ready for onload callback

* Require bokeh 2.2 for onload
  • Loading branch information
philippjfr committed Sep 17, 2020
1 parent eaa42d9 commit 15d660b
Showing 1 changed file with 7 additions and 1 deletion.
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

0 comments on commit 15d660b

Please sign in to comment.