kernel.core.notification

Module: kernel.core.notification

Inheritance diagram for IPython.kernel.core.notification:

The IPython Core Notification Center.

See docs/source/development/notification_blueprint.txt for an overview of the notification module.

NotificationCenter

class IPython.kernel.core.notification.NotificationCenter

Bases: object

Synchronous notification center

Examples

>>> import IPython.kernel.core.notification as notification
>>> def callback(theType, theSender, args={}):
...     print theType,theSender,args
...     
>>> notification.sharedCenter.add_observer(callback, 'NOTIFICATION_TYPE', None)
>>> notification.sharedCenter.post_notification('NOTIFICATION_TYPE', object()) # doctest:+ELLIPSIS
NOTIFICATION_TYPE ...
__init__()
add_observer(callback, theType, sender)

Add an observer callback to this notification center.

The given callback will be called upon posting of notifications of the given type/sender and will receive any additional kwargs passed to post_notification.

Parameters:

observerCallback : callable

Callable. Must take at least two arguments::

observerCallback(type, sender, args={})

theType : hashable

The notification type. If None, all notifications from sender will be posted.

sender : hashable

The notification sender. If None, all notifications of theType will be posted.

post_notification(theType, sender, **kwargs)

Post notification (type,sender,**kwargs) to all registered observers.

Implementation notes:

  • If no registered observers, performance is O(1).
  • Notificaiton order is undefined.
  • Notifications are posted synchronously.
remove_all_observers()
Removes all observers from this notification center