Skip to content

Commit

Permalink
Ensure messages are deduplicated based on model id (#205)
Browse files Browse the repository at this point in the history
* Ensure messages are deduplicated based on model id

* Fix types
  • Loading branch information
philippjfr authored Apr 19, 2024
1 parent 58e8954 commit 33d4e52
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type DocumentChangedEvent = any
type Receiver = any
type Fragment = any
type HasProps = any
type Ref = any

const { keys, values } = Object

Expand All @@ -29,6 +28,10 @@ export type RenderBundle = {
div: string
}

export interface Ref {

Check warning on line 31 in src/widgets.ts

View workflow job for this annotation

GitHub Actions / build

Interface name `Ref` must match the RegExp: /^I[A-Z]/u
id: string
}

export interface DocumentChanged {

Check warning on line 35 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
Expand All @@ -37,7 +40,7 @@ export interface DocumentChanged {
export interface ModelChanged extends DocumentChanged {

Check warning on line 40 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
model: Ref
new: unknown
attr: string
}
Expand Down Expand Up @@ -169,7 +172,7 @@ export class BokehView extends DOMWidgetView {
if (new_msg.kind != msg.kind) {
new_msgs.push(msg)
} else if (msg.kind == 'ModelChanged' && new_msg.kind == 'ModelChanged') {
if (msg.id != new_msg.id || msg.attr != new_msg.attr) {
if (msg.model.id != new_msg.model.id || msg.attr != new_msg.attr) {
new_msgs.push(msg)
}
} else if (msg.kind == 'MessageSent' && new_msg.kind == 'MessageSent') {
Expand Down

0 comments on commit 33d4e52

Please sign in to comment.