mode.signals — mode-ng 0.4.0 documentation

# `mode.signals`

Signals - implementation of the Observer pattern.

class mode.signals.BaseSignal(*, name: Optional[str] = None, owner: Optional[Type] = None, loop: Optional[AbstractEventLoop] = None, default_sender: Optional[Any] = None, receivers: Optional[MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]] = None, filter_receivers: Optional[MutableMapping[Any, MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]]] = None)

  Base class for signal/observer pattern.

  asdict() → Mapping[str, Any]
  clone(**kwargs: Any) → BaseSignalT
  connect(fun: Optional[Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]] = None, **kwargs: Any) → Callable
  disconnect(fun: Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]], *, weak: bool = False, sender: Optional[Any] = None) → None
  property ident: str
  iter_receivers(sender: T_contra) → Iterable[Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]]
  property label: str
  unpack_sender_from_args(*args: Any) → tuple[T, tuple[Any, ...]]
  with_default_sender(sender: Optional[Any] = None) → BaseSignalT

class mode.signals.Signal(*, name: Optional[str] = None, owner: Optional[Type] = None, loop: Optional[AbstractEventLoop] = None, default_sender: Optional[Any] = None, receivers: Optional[MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]] = None, filter_receivers: Optional[MutableMapping[Any, MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]]] = None)

  Asynchronous signal (using `async def` functions).

  clone(**kwargs: Any) → SignalT
  async send(*args: Any, **kwargs: Any) → None
  with_default_sender(sender: Any = None) → SignalT

class mode.signals.SyncSignal(*, name: Optional[str] = None, owner: Optional[Type] = None, loop: Optional[AbstractEventLoop] = None, default_sender: Optional[Any] = None, receivers: Optional[MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]] = None, filter_receivers: Optional[MutableMapping[Any, MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]]] = None)

  Signal that is synchronous (using regular `def` functions).

  clone(**kwargs: Any) → SyncSignalT
  send(*args: Any, **kwargs: Any) → None
  with_default_sender(sender: Any = None) → SyncSignalT