Warning | ||
---|---|---|
| ||
This page has not been adjusted for version 1.0 of the pico-engine |
Having a pico that maintains a collection of other picos is a pattern that is often useful.
...
Code Block | ||
---|---|---|
| ||
rule collection_subscriptions { select when wrangler child_initialized pre { eci = event:attr("eci"); collection_eci = get_wellKnown_eci(eci); } if collection_eci then noop(); fired { raise grouper event "need_subscriptions" attributes event:attrattrs("rs_attrs").put("collection_eci",collection_eci); } } |
...
This KRL code will respond to the internal event, expecting the collection_eci
and the child_specs
given to wrangler earlier (wrangler renames it rs_attrs
for some reason).
Code Block | ||
---|---|---|
| ||
rule collection_subscription_requests { select when grouper need_subscriptions foreach by_prefix(event:attr("name_prefix")) setting(room_name,tag_id) pre { eci = building:eci(tag_id); wellKnown_Tx = get_wellKnown_eci(eci).klog("wellKnown_Tx"); } if wellKnown_Tx then every { event:send({"eci":eci,"domain":"wrangler","type":"subscription", "attrs": { "wellKnown_Tx": event:attr("collection_eci"), "Rx_role": "member", "Tx_role": "collection", "name": tag_id, "channel_type": "subscription" } }) } } |
...