gobj_subscribe_event()
#
The gobj_subscribe_event
function subscribes a subscriber
GObj to an event
emitted by a publisher
GObj, with optional configuration parameters.
Prototype
json_t *gobj_subscribe_event(
hgobj publisher,
gobj_event_t event,
json_t *kw,
hgobj subscriber
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
The GObj that emits the event. |
|
|
The event to subscribe to. |
|
|
A JSON object containing subscription options, including |
|
|
The GObj that will receive the event notifications. |
Return Value
Returns a JSON object representing the subscription if successful, or NULL
on failure.
Notes
The event
must be in the publisher’s output event list unless the gcflag_no_check_output_events
flag is set.
If a subscription with the same parameters already exists, it will be overridden.
The __config__
field in kw
can include options such as __hard_subscription__
(permanent subscription) and __own_event__
(prevents further propagation if the subscriber handles the event).
The function calls gobj_unsubscribe_event()
to remove duplicate subscriptions before adding a new one.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples