[docs]classNotificationHandle(NotificationProps,AssignablePropsBase[_NotificationHandleState]):"""Handle for a notification in our visualizer."""def__init__(self,impl:_NotificationHandleState)->None:self._impl=impl@overridedef_queue_update(self,name:str,value:Any)->None:"""Queue an update message with the property change."""# For notifications, we'll just send the whole props object when a# property is reassigned. Deduplication in the message buffer will# debounce this when multiple properties are updated in succession.delname,valueself._sync_with_client("update")def_sync_with_client(self,mode:Literal["show","update"])->None:msg=NotificationMessage(mode,self._impl.uuid,self._impl.props)self._impl.websock_interface.queue_message(msg)
[docs]defremove(self)->None:self._impl.websock_interface.get_message_buffer().remove_from_buffer(# Don't send outdated GUI updates to new clients.# This is brittle...lambdamessage:getattr(message,"uuid",None)==self._impl.uuid)msg=RemoveNotificationMessage(self._impl.uuid)self._impl.websock_interface.queue_message(msg)