Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Wrangler raises an event, ruleset_added on successful installation of a rid with the installed rid as an attribute rids. This event is meant for developers to catch in rulesets for initializing state, which could include channel creation, subscription request, and child pico creation. Initialization rules should be listed first in rulesets, because rulesets execute in order this will cause the initialization rule to run first.  This model of initialization has replaced prototypes. 

Create Channel On Installation Example

This example is taken from io.picolabs.subscription ruleset. 

Code Block
languagejs
titleinitialization example
linenumberstrue
rule create_wellKnown_Rx{
  select when wrangler ruleset_added where rids >< meta:rid
  pre{ channel = wellKnown_Rx() }
  if(channel.isnull() || channel{"type"} != "Tx_Rx") then
    engine:newChannel(meta:picoId, "wellKnown_Rx", "Tx_Rx")
  fired{
    raise Tx_Rx event "wellKnown_Rx_created" attributes event:attrs;
  }
  else{
    raise Tx_Rx event "wellKnown_Rx_not_created" attributes event:attrs; //exists
  }
}

Create well known Rx rule selects on ruleset_added event where rids matches its own ruleset rid. Checks for a well known channel, and creates it if one does not exist. Then raises an event detailing the creation. This rule guarantees a well known channel exist, which is a dependency of subscriptions.

Warning: Deprecated, Untested Example

...

of prototypes


Picos can be created using prototypes that describe what state a pico should be created in.

...