Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: (Classic)

Learning Objectives

After completing this lesson, you will be able to do the following:

  • Explain what entity variables are.
  • Use rules and functions to interact with entity variables.
  • Use entity variables to create persistent picos.
  • Understand how rules can use explicit events to chain rules


HTML Comment

Concepts

  Persistent variables

    • ent
  • Add persistent vars to hello world app
    • Add a rule
    • Rule takes first and last names as event attr.
    • Stores in an entity var (JSON)
  • Add function to query value of entity var


Prerequisites

You should have completed the following lessons:

Picos Represent State

Picos (Persistent Compute Objects) contain state that can be changed in response to events. Picos persist their state using entity variables.

We will learn more about entity variables by adding persistence to our hello_world ruleset from (Classic) Quickstart.

Add Persistence to hello_world

Let's change the hello_world ruleset to know your name by default.

...

Test echo hello event without a name attribute.

Cool Beans!

Complex Entity Variables

We used an entity variable to store a simple string, but you can also store complex objects in your entity variables. To search deep branches of your object you provide hash paths.

...

Test your greeting by raising an echo hello event with an id attribute.

Splendid!

Querying Persistent Variables

We could use our entity variable how it is but the code will quickly become un-readable.

...

Sweet, you now can add as many users as you want and have your ruleset say hello to each user.

Next Level

We have multiple users our ruleset can recognize with an id, But it would be so much cooler if we knew how many times our ruleset says hello to a user.

...