Dispatch¶
- detroit_live.dispatch(*typenames: str) Dispatch¶
Creates a new dispatch for the specified event types. Each type is a string, such as
"start"or"end".- Parameters:
typenames (str) – Typename value such as
"start"or"end"- Returns:
Dispatch object
- Return type:
- class detroit_live.dispatch.dispatch.Dispatch(typenames: dict[str, list[tuple[str, Callable[[...], None]]]])¶
- __call__(typename: str, *args: Any)¶
Invokes each registered callback for the specified type, passing the callback the specified arguments, with that as the this context.
- Parameters:
typename (str) – Typename
args (Any) – Additional arguments passed to the
callbackfunction
- on(typename: str, callback: Callable[[...], None] | None = None) Dispatch¶
Adds, removes or gets the
callbackfor the specified typenames. If a callback function is specified, it is registered for the specified (fully-qualified) typenames. If acallbackwas already registered for the given typenames, the existing callback is removed before the new callback is added.The specified typenames is a string, such as start or end.foo. The type may be optionally followed by a period (.) and a name; the optional name allows multiple callbacks to be registered to receive events of the same type, such as start.foo and start.bar. To specify multiple typenames, separate typenames with spaces, such as start end or start.foo start.bar.
To remove all callbacks for a given name
foo, saydispatch.on(".foo", null).If
callbackis not specified, returns the current callback for the specified typenames, if any. If multiple typenames are specified, the first matching callback is returned.- Parameters:
typename (str) – Typename value
callback (Callback | None) – Callback
- Returns:
Itself
- Return type:
- parse_typenames(typenames: str) list[tuple[str, str]]¶