Skip to content

Commit 86d733d

Browse files
authored
Handle comm_open messages containing new widget state (#98)
* Handle comm_open messages containing new widget state * Add additional guards * Do not drop defaults
1 parent 9f59ab3 commit 86d733d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ipywidgets_bokeh/src/manager.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,16 @@ export class WidgetManager extends HTMLManager {
128128
this.kernel = this.kernel_manager.connectTo({model: kernel_model, handleComms: true})
129129
this.kernel.registerCommTarget(this.comm_target_name, (comm, msg) => {
130130
const model = this._model_objs.get(msg.content.comm_id)
131+
const comm_wrapper = new shims.services.Comm(comm)
132+
if (model == null) {
133+
this.handle_comm_open(comm_wrapper, msg).then((model) => {
134+
if (model != null && !model.comm_live) {
135+
const comm_wrapper = new shims.services.Comm(comm)
136+
this._attach_comm(comm_wrapper, model)
137+
}
138+
})
139+
}
131140
if (model != null && !model.comm_live) {
132-
const comm_wrapper = new shims.services.Comm(comm)
133141
this._attach_comm(comm_wrapper, model)
134142
}
135143
this._model_objs.delete(msg.content.comm_id)

ipywidgets_bokeh/widget.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ def __init__(self, *, widget: Widget, **kwargs):
3737
spec = widget.get_view_spec()
3838
state = Widget.get_manager_state(widgets=[widget])
3939
state["full_state"] = state["state"]
40-
state["state"] = embed.dependency_state([widget], drop_defaults=True)
40+
state["state"] = embed.dependency_state([widget], drop_defaults=False)
4141
self.bundle = dict(spec=spec, state=state)

0 commit comments

Comments
 (0)