hscommon.notify — dupeGuru 4.0.4 documentation

# dupeGuru 4.0.4 documentation

## hscommon.notify

Very simple inter-object notification system.

This module is a brain-dead simple notification system involving a `Broadcaster` and a `Listener`. A listener can only listen to one broadcaster. A broadcaster can have multiple listeners. If the listener is connected, whenever the broadcaster calls `notify()`, the method with the same name as the broadcasted message is called on the listener.

class `hscommon.notify.` `Broadcaster`

  Broadcasts messages that are received by all listeners.

  `notify`(msg)

    Notify all connected listeners of `msg`.

    That means that each listeners will have their method with the same name as `msg` called.

class `hscommon.notify.` `Listener`(broadcaster)

  A listener is initialized with the broadcaster it’s going to listen to. Initially, it is not connected.

  `bind_messages`(messages, func)

    Binds multiple message to the same function.

    Often, we perform the same thing on multiple messages. Instead of having the same function repeated again and agin in our class, we can use this method to bind multiple messages to the same function.

  `connect`()

    Connects the listener to its broadcaster.

  `disconnect`()

    Disconnects the listener from its broadcaster.

class `hscommon.notify.` `Repeater`(broadcaster)