Skip to content

Commit

Permalink
Do not drop events while blocked (#204)
Browse files Browse the repository at this point in the history
* Do not drop events while blocked

* Fix indentation

* Fix logic bug
  • Loading branch information
philippjfr authored Apr 18, 2024
1 parent 38d8fd5 commit ee1eb50
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class BokehView extends DOMWidgetView {
private _receiver: Receiver
private _blocked: boolean
private _msgs: any[]
private _events: any[]
private _idle: boolean
private _combine: boolean

Expand Down Expand Up @@ -175,7 +176,7 @@ export class BokehView extends DOMWidgetView {
if (
msg.msg_data.event_values.model == null ||
msg.msg_data.event_values.model.id !=
new_msg.msg_data.event_values.model.id ||
new_msg.msg_data.event_values.model.id ||
msg.msg_data.event_name != new_msg.msg_data.event_name
) {
new_msgs.push(msg)
Expand All @@ -198,6 +199,7 @@ export class BokehView extends DOMWidgetView {

protected _change_event(event: DocumentChangedEvent): void {
if (this._blocked) {
this._events.push(event)
return
}
const { Serializer } = bk_require('core/serialization')
Expand Down Expand Up @@ -228,6 +230,11 @@ export class BokehView extends DOMWidgetView {
this._document.apply_json_patch(comm_msg.content, comm_msg.buffers)
} finally {
this._blocked = false
const events = [...this._events]
this._events = []
for (const event of events) {
this._change_event(event)
}
}
}
}
Expand Down

0 comments on commit ee1eb50

Please sign in to comment.