Versions Compared

Key

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

...

This function is just a wrapper. You don't need to wrap Wrangler functions to use them within the ruleset, but we do if we want to make them visible via the Sky Cloud API for usable outside the pico. We also have to declare that our ruleset shares the function in the meta block.

...

Now we can use showChildren and sections using the "Testing" tab.

Querying Children

You may need to query children. The Events and Queries lesson showed how to use HTTP to query a pico. But we wouldn’t use that method to query another pico from KRL. Wrangler provides a function for doing this called picoQuery(). picoQuery() uses ctx:query() to make the query if the pico is hosted on the same engine as the pico making the query. Otherwise it uses HTTP.

Assuming that we have this statement in the meta block of our ruleset:

Code Block
    use module io.picolabs.wrangler alias wrangler

We can use picoQuery()  provided by Wrangler, as shown in the following rule fragment:

Code Block
  pre {
    eci = eci_to_other_pico;
    args = {"arg1": val1, "arg2": val2};
    answer = wrangler:picoQuery(eci,"my.ruleset.id","myFunction",{}.put(args));
  }
  if answer{"error"}.isnull() then noop();
  fired {
    // process using answer
  }

More information can be found in the Wrangler documentation for picoQuery() and in Accessing Functions Shared by Another Pico.

Maintaining information about child picos

...