Skip to content

Commit

Permalink
Merge pull request #58 from maartenbreddels/fix_fire_event
Browse files Browse the repository at this point in the history
fix: .fire_event silently passes on exceptions
  • Loading branch information
maartenbreddels authored Feb 23, 2023
2 parents 9979d93 + ae5f0f4 commit 38fbbd3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ipyvue/VueWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ def on_event(self, event_and_modifiers, callback, remove=False):
if len(difference) != 0:
self._events = list(self._event_handlers_map.keys())

def fire_event(self, event, data):
self._event_handlers_map[event](self, event, data)
def fire_event(self, event, data=None):
"""Manually trigger an event handler on the Python side."""
dispatcher = self._event_handlers_map[event]
# we don't call via the dispatcher, since that eats exceptions
for callback in dispatcher.callbacks:
callback(self, event, data or {})

def _handle_event(self, _, content, buffers):
event = content.get("event", "")
Expand Down

0 comments on commit 38fbbd3

Please sign in to comment.