Skip to content

Commit

Permalink
Only serialize models not already known to a document (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpap authored Apr 17, 2024
1 parent 9a55cac commit 5f0075f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Document = any
type DocumentChangedEvent = any
type Receiver = any
type Fragment = any
type HasProps = any
type Ref = any

const { keys, values } = Object

Expand Down Expand Up @@ -199,7 +201,11 @@ export class BokehView extends DOMWidgetView {
return
}
const { Serializer } = bk_require('core/serialization')
const serializer = new Serializer()
const references: Map<HasProps, Ref> = new Map()
for (const model of event.document._all_models.values()) {
references.set(model, model.ref())
}
const serializer = new Serializer({references})
const event_rep = serializer.encode(event)
event_rep.event = 'jsevent'
this._send(event_rep)
Expand Down

0 comments on commit 5f0075f

Please sign in to comment.