Calling an extension from file save hooks

Hello,

I am extending some functionalities of JupyterLab and would like to ask about JupyterLab extensions and Jupyter server hooks.

Currently, let’s say I have a post_save_hook which raises an HTTPError to display a dialog on failure, as suggested.

In addition to just an error modal, would it be possible to:

  1. improve error message UI of the modal
  2. show success as toast notification

Since this requires the DOM to be updated, I was wondering if the approach should be to:

  1. Create a JupyterLab front-end extension that show notifications on receiving new messages
  2. pre_save_hooks and post_save_hooks emit messages to the extension

Is 2. possible and how should I go about it?