# Dispatch¶

This section covers the methods and classes used for handing internal and external events. For more information see Dispatch

## Signals¶

class tbone.dispatch.signals.Signal

Base class for all signals

connect(receiver, sender)

Connects a signal to a receiver function

Parameters: receiver – The callback function which will be connected to this signal sender – Specifies a particular sender to receive signals from. Used to limit the receiver function to signal from particular sender types
coroutine send(sender, **kwargs)

send a signal from the sender to all connected receivers

## Channels¶

class tbone.dispatch.channels.Channel

Abstract base class for all Channel implementations. Provides pure virtual methods for subclass implementations

kickoff()

Initiates the channel and start listening to events. This method should be called at the startup sequence of the app, or as soon as events should be listened to. Pushes consume_events into the event loop.

coroutine publish(key, data=None)

Publish an event to the channel, to be sent to all subscribers

Parameters: key – The name of the event data – The data to be passed with the event. The data must be such that it can be encoded to JSON
subscribe(event, subscriber)

Subscribe to channel events.

Parameters: event – The name of the event to subscribe to. String based subscriber – A Carrier type object which delivers the message to its target
class tbone.dispatch.channels.mem.MemoryChannel(**kwargs)

Represents a channel for event pub/sub based on in-memory queue. uses asyncio.Queue to manage events.