@yuneta/gobj-js 7.25.7 → 7.25.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -300,6 +300,41 @@ gobj_subscribe_event(source_gobj, "EV_DATA_READY", {}, subscriber_gobj);
300
300
  gobj_unsubscribe_event(source_gobj, "EV_DATA_READY", {}, subscriber_gobj);
301
301
  ```
302
302
 
303
+ **Which kw a subscriber gets** (since 7.25.8, the same rule as the C kernel):
304
+
305
+ - A subscription with a non-empty `__local__` (keys removed) or `__global__`
306
+ (keys added) gets a **twin** of the published kw: a new top-level object,
307
+ with the nested values shared. `__global__` goes in as a copy. What one
308
+ subscription removes or adds reaches only its own subscriber.
309
+ - Every other subscriber gets the **same** kw as the publisher. A receiver that
310
+ changes the kw it got must change a copy of its own (`C_IEVENT_CLI`'s
311
+ `mt_inject_event` does this before it writes its ievent stack).
312
+ - `__filter__` and `mt_publication_filter` see the publisher's kw.
313
+
314
+ ```javascript
315
+ gobj_subscribe_event(pub, "EV_X", {__global__: {tag: "a"}}, sub_a); // gets {v: 1, tag: "a"}
316
+ gobj_subscribe_event(pub, "EV_X", {__local__: {secret: 0}}, sub_b); // gets {v: 1}
317
+ gobj_subscribe_event(pub, "EV_X", {__filter__: {v: 1}}, sub_c); // gets the publisher's kw
318
+ gobj_publish_event(pub, "EV_X", {v: 1, secret: "s"}); // the kw stays {v: 1, secret: "s"}
319
+ ```
320
+
321
+ **A renamed event** (since 7.25.9, the same rule as the C kernel):
322
+ `{__config__: {__rename_event_name__: "EV_A"}}` sends the subscriber `EV_A`
323
+ instead of the published event, with `__original_event_name__` in the kw, when
324
+ some gclass declares `EV_A` (a rename nobody declares is logged and ignored).
325
+ The rename is part of what the subscription IS: a renamed subscription over a
326
+ plain one is a second one, while a plain kw is a wildcard, so a plain
327
+ subscription over a renamed one replaces it and a plain unsubscribe removes
328
+ both.
329
+
330
+ ```javascript
331
+ gobj_subscribe_event(pub, "EV_ON_MESSAGE", {}, sub); // one
332
+ gobj_subscribe_event(pub, "EV_ON_MESSAGE",
333
+ {__config__: {__rename_event_name__: "EV_A"}}, sub); // two
334
+ gobj_publish_event(pub, "EV_ON_MESSAGE", {}); // sub gets EV_ON_MESSAGE, and EV_A
335
+ gobj_unsubscribe_event(pub, "EV_ON_MESSAGE", {}, sub); // none
336
+ ```
337
+
303
338
  ### GObject Tree (Yuno)
304
339
 
305
340
  GObjects form a parent-child tree. The root is the **Yuno**. Services live directly under the Yuno. Each GObject has exactly one parent (except the Yuno itself).