Subscribable (Core)#

alts.core.subscribable
class DelayedPublisher[source]#

Bases: Publisher

Description
A DelayedPublisher, as opposed to a Publisher, updates through the update() method only if it has been requested by executing the request_update() method after the last successful update.
request_update()[source]#

requeste_update(self) -> None | Description | Ensures an update on the next update() call.

update(self) None[source]#
Description
Updates its subscribers only there has been a request_update() since the last update.
class Publisher[source]#

Bases: Configurable, Subscribable

Description
A Publisher is a simple Subscribable which just calls the subscribers’ callables when updated.
subscribe(self, subscriber, callable) None[source]#
Description
Adds the (subscriber, callable) tuple to its record.
If no callable is passed, defaults to subscriber.update.
Parameters:
  • subscriber (Subscriber) – The new subscriber

  • callable (Callable) – Gets called on update (default= subscriber.update)

update(self) None[source]#
Description
Calls the associated callable of each subscriber.
Raises:

TypeErrorcallable is not a Callable

class Subscribable[source]#

Bases: object

Description
A Subscribable can have subscribers. When the Subscribable is updated, it calls the given Callable for each subscriber.
abstract subscribe(self, subscriber, callable) None[source]#
Description
Remembers subscriber and calls the given callable if one is given.
Parameters:
  • subscriber (Subscriber) – The new subscriber

  • callable (Callable) – This gets called when the Subscribable updates (default= None)

Raises:

NotImplementedError – Method is abstract

abstract update() None[source]#

updae(self) -> None | Description | Updates all subscribers given their callables.

Raises:

NotImplementedError – Method is abstract