observer
Publish/Subscribe Event Pattern
Functions
| Function | Description |
|---|---|
obs_new | Create an event bus. |
obs_find_topic | Internal: find or create slot for topic. |
obs_subscribe | Subscribe a handler function pointer to a topic. Handler signature: fn(data: … |
obs_emit_i | Emit an event to all subscribers of a topic. Calls each handler with the data… |
obs_unsubscribe_all | Remove all handlers for a topic. |
obs_subscriber_count | Number of subscribers for a topic. |
Details
obs_new
fn obs_new(max_topics: i64) -> &i64Create an event bus.
obs_find_topic
fn obs_find_topic(bus: &i64, topic: i64) -> i64Internal: find or create slot for topic.
obs_subscribe
fn obs_subscribe(bus: &i64, topic: i64, fn_ptr: i64)Subscribe a handler function pointer to a topic. Handler signature: fn(data: i64) or fn(data: &i64)
obs_emit_i
fn obs_emit_i(bus: &i64, topic: i64, val: i64)Emit an event to all subscribers of a topic. Calls each handler with the data argument.
obs_unsubscribe_all
fn obs_unsubscribe_all(bus: &i64, topic: i64)Remove all handlers for a topic.
obs_subscriber_count
fn obs_subscriber_count(bus: &i64, topic: i64) -> i64Number of subscribers for a topic.