...
and specify additional processing in some_function
(defined in lines 6-8) that it shares (in line 3) to endpoints, and/or specify rules like some_rule
(defined in lines 10-14) that take action on the collection's members when certain events occur.
When a member is added
Since members of the collection are determined by subscriptions, your ruleset can listen for wrangler:subscription_added
events to do something when a new member joins your collection. Since your pico might participate in other subscriptions, only those in which the roles are "collection"
and "member"
would be applicable.
Code Block | ||
---|---|---|
| ||
rule new_member {
select when wrangler subscription_added
pre {
pertinent = event:attr("Rx_role")=="collection"
&& event:attr("Tx_role")=="member";
}
if pertinent then noop();
fired {
raise collection event "new_member" attributes event:attrs
}
} |
The event attributes available are those surrounding a subscription in general. Some of these might be useful when a new member arrives into your collection
Tip | ||
---|---|---|
| ||
|
When a member is removed
Your ruleset might wish to listen to the event wrangler:subscription_removed
which will be raised when a subscription is removed from your pico. Such events which are applicable to membership in your collection could then be handled appropriately.
Code Block | ||
---|---|---|
| ||
rule new_member {
select when wrangler subscription_removed
pre {
pertinent = event:attr("Rx_role")=="collection"
&& event:attr("Tx_role")=="member";
}
if pertinent then noop();
fired {
raise collection event "member_removed" attributes event:attrs
}
} |