carb.events¶
-
class
carb.events.
IEvent
¶ Bases:
pybind11_builtins.pybind11_object
Event.
Event has an Event type, a sender id and a payload. Payload is a dictionary like item with arbitrary data.
-
consume
(self: carb.events._events.IEvent) → None¶ Consume event to stop it propagating to other listeners down the line.
-
property
payload
¶
-
property
sender
¶
-
property
type
¶
-
-
class
carb.events.
IEventStream
¶ Bases:
pybind11_builtins.pybind11_object
-
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
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
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
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
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
Event
immediately without putting it into stream.- Parameters
event_type (int) –
Event
type.sender (int) – Sender id. Unique can be acquired using
acquire_unique_sender_id()
.dict (typing.Dict) –
Event
payload.
-
property
event_count
¶
-
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
(
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
Event
into stream.- Parameters
event_type (int) –
Event
type.sender (int) – Sender id. Unique can be acquired using
acquire_unique_sender_id()
.dict (typing.Dict) –
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 (
Event
) if stream is not empty or return None.
-
-
class
carb.events.
IEvents
¶ Bases:
pybind11_builtins.pybind11_object
-
acquire_unique_sender_id
(self: carb.events._events.IEvents) → int¶ Acquire unique sender id.
Call
release_unique_sender_id()
when it is not needed anymore. It can be reused then.
-
create_event_stream
(self: carb.events._events.IEvents) → carb.events._events.IEventStream¶ Create new .EventStream.
-
release_unique_sender_id
(self: carb.events._events.IEvents, arg0: int) → None¶
-
-
class
carb.events.
ISubscription
¶ Bases:
pybind11_builtins.pybind11_object
Subscription holder.
-
unsubscribe
(self: carb.events._events.ISubscription) → None¶
-
-
carb.events.
acquire_events_interface
() → carb::events::IEvents¶
-
carb.events.
get_events_interface
() → carb.events._events.IEvents¶ Returns cached
carb.events.IEvents
interface
-
carb.events.
type_from_string
(arg0: str) → int¶