IEventStream
- class carb.events.IEventStream
Methods
__init__
(*args, **kwargs)create_subscription_to_pop
(self, fn[, ...])Subscribes to event dispatching on the stream.
create_subscription_to_pop_by_type
(self, ...)Subscribes to event dispatching on the stream.
create_subscription_to_push
(self, fn[, ...])Subscribes to pushing events into stream.
create_subscription_to_push_by_type
(self, ...)Subscribes to pushing events into stream.
dispatch
(self[, event_type, sender, payload])Dispatch :class:`.Event` immediately without putting it into stream.
get_subscription_to_pop_order
(self, name)Get subscription to pop order by name of subscription.
get_subscription_to_push_order
(self, name)Get subscription to push order by name of subscription.
next_event
([order, name])Async wait for next event.
next_event_by_type
(event_type[, order, name])Async wait for next event of particular type.
pop
(self)Pop event.
pump
(self)Pump event stream.
push
(self[, event_type, sender, payload])Push :class:`.Event` into stream.
set_subscription_to_pop_order
(self, name, order)Set subscription to pop order by name of subscription.
set_subscription_to_push_order
(self, name, order)Set subscription to push order by name of subscription.
try_pop
(self)Try pop event.
Attributes
event_count
- __init__(*args, **kwargs)
- create_subscription_to_pop(self: carb.events._events.IEventStream, fn: Callable[[carb.events._events.IEvent], None], order: int = 0, name: str = '') carb.events._events.ISubscription
Subscribes to event dispatching on the stream.
See :class:`.Subscription` for more information on subscribing mechanism.
- Parameters
fn – The callback to be called on event dispatch.
- Returns
The subscription holder.
- create_subscription_to_pop_by_type(self: carb.events._events.IEventStream, event_type: int, fn: Callable[[carb.events._events.IEvent], None], order: int = 0, name: str = '') carb.events._events.ISubscription
Subscribes to event dispatching on the stream.
See :class:`.Subscription` for more information on subscribing mechanism.
- Parameters
event_type – Event type to listen to.
fn – The callback to be called on event dispatch.
- Returns
The subscription holder.
- create_subscription_to_push(self: carb.events._events.IEventStream, fn: Callable[[carb.events._events.IEvent], None], order: int = 0, name: str = '') carb.events._events.ISubscription
Subscribes to pushing events into stream.
See :class:`.Subscription` for more information on subscribing mechanism.
- Parameters
fn – The callback to be called on event push.
- Returns
The subscription holder.
- create_subscription_to_push_by_type(self: carb.events._events.IEventStream, event_type: int, fn: Callable[[carb.events._events.IEvent], None], order: int = 0, name: str = '') carb.events._events.ISubscription
Subscribes to pushing events into stream.
See :class:`.Subscription` for more information on subscribing mechanism.
- Parameters
event_type – Event type to listen to.
fn – The callback to be called on event push.
- Returns
The subscription holder.
- dispatch(self: carb.events._events.IEventStream, event_type: int = 0, sender: int = 0, payload: dict = {}) None
Dispatch :class:`.Event` immediately without putting it into stream.
- Parameters
event_type (int) – :class:`.Event` type.
sender (int) – Sender id. Unique can be acquired using :func:`.acquire_unique_sender_id`.
dict (Dict) – :class:`.Event` payload.
- get_subscription_to_pop_order(self: carb.events._events.IEventStream, name: str) object
Get subscription to pop order by name of subscription. Return None if subscription was not found.
- get_subscription_to_push_order(self: carb.events._events.IEventStream, name: str) object
Get subscription to push order by name of subscription. Return None if subscription was not found.
- async next_event(order: int = 0, name: str = '')
Async wait for next event.
- async next_event_by_type(event_type: int, order: int = 0, name: str = '')
Async wait for next event of particular type.
- pop(self: carb.events._events.IEventStream) carb.events._events.IEvent
Pop event.
This function blocks execution until there is an event to pop.
- Returns
(:class:`.Event`) object. You own this object, it can be stored.
- pump(self: carb.events._events.IEventStream) None
Pump event stream.
Dispatches all events in a stream.
- push(self: carb.events._events.IEventStream, event_type: int = 0, sender: int = 0, payload: dict = {}) None
Push :class:`.Event` into stream.
- Parameters
event_type (int) – :class:`.Event` type.
sender (int) – Sender id. Unique can be acquired using :func:`.acquire_unique_sender_id`.
dict (Dict) – :class:`.Event` payload.
- set_subscription_to_pop_order(self: carb.events._events.IEventStream, name: str, order: int) bool
Set subscription to pop order by name of subscription.
- set_subscription_to_push_order(self: carb.events._events.IEventStream, name: str, order: int) bool
Set subscription to push order by name of subscription.
- try_pop(self: carb.events._events.IEventStream) carb.events._events.IEvent
Try pop event.
- Returns
Pops (:class:`.Event`) if stream is not empty or return `None`.