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

Do not drop events while blocked #204

Merged
merged 3 commits into from
Apr 18, 2024
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
9 changes: 8 additions & 1 deletion src/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
div: string
}

export interface DocumentChanged {

Check warning on line 32 in src/widgets.ts

View workflow job for this annotation

GitHub Actions / build

Interface name `DocumentChanged` must match the RegExp: /^I[A-Z]/u
event: 'jsevent'
kind: string
}

export interface ModelChanged extends DocumentChanged {

Check warning on line 37 in src/widgets.ts

View workflow job for this annotation

GitHub Actions / build

Interface name `ModelChanged` must match the RegExp: /^I[A-Z]/u
event: 'jsevent'
kind: 'ModelChanged'
id: string
Expand All @@ -42,7 +42,7 @@
attr: string
}

export interface MessageSent extends DocumentChanged {

Check warning on line 45 in src/widgets.ts

View workflow job for this annotation

GitHub Actions / build

Interface name `MessageSent` must match the RegExp: /^I[A-Z]/u
event: 'jsevent'
kind: 'MessageSent'
msg_data: {
Expand Down Expand Up @@ -83,6 +83,7 @@
private _receiver: Receiver
private _blocked: boolean
private _msgs: any[]
private _events: any[]
private _idle: boolean
private _combine: boolean

Expand All @@ -97,7 +98,7 @@
this._receiver = new Receiver()
this.model.on('change:render_bundle', () => this.render())
if (
(window as any).Jupyter != null &&

Check warning on line 101 in src/widgets.ts

View workflow job for this annotation

GitHub Actions / build

Expected '!==' and instead saw '!='
(window as any).Jupyter.notebook != null
) {
// Handle classic Jupyter notebook
Expand Down Expand Up @@ -175,7 +176,7 @@
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 @@

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 @@
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
Loading