Skip to content

Commit

Permalink
Ensure stream and patch events do not boomerang
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Nov 10, 2021
1 parent 7d418e9 commit a34aef9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions panel/reactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,13 @@ def _update_selected(self, *events, indices=None):
for ref, (m, _) in self._models.items():
self._apply_update(events, msg, m.source.selected, ref)

def _apply_stream(self, ref, model, stream, rollover):
self._changing[ref] = ['data']
try:
model.source.stream(stream, rollover)
finally:
del self._changing[ref]

@updating
def _stream(self, stream, rollover=None):
self._processed, _ = self._get_data()
Expand All @@ -682,9 +689,16 @@ def _stream(self, stream, rollover=None):
if comm and 'embedded' not in root.tags:
push(doc, comm)
else:
cb = partial(m.source.stream, stream, rollover)
cb = partial(self._apply_stream, ref, m, stream, rollover)
doc.add_next_tick_callback(cb)

def _apply_patch(self, ref, model, patch):
self._changing[ref] = ['data']
try:
model.source.patch(patch)
finally:
del self._changing[ref]

@updating
def _patch(self, patch):
for ref, (m, _) in self._models.items():
Expand All @@ -697,7 +711,7 @@ def _patch(self, patch):
if comm and 'embedded' not in root.tags:
push(doc, comm)
else:
cb = partial(m.source.patch, patch)
cb = partial(self._apply_patch, ref, m, patch)
doc.add_next_tick_callback(cb)

def _update_manual(self, *events):
Expand Down

0 comments on commit a34aef9

Please sign in to comment.