Reading Variables

How can I read the value of a variable in Lasp?

To read variables at a particular point in time, you can use the query command provided by Lasp. This command will return the instantaneous value of the variable, and is not guaranteed to be deterministic or monotonic.

> lasp:query({<<"set">>, state_orset}).

If you'd like to have a function executed every time a variable changes, Lasp provides a stream operator as well. This will ensure that the function is executed each time the value of the variable changes monotonically; however, the function will does not guarantee that the value provided will be monotonic.

> Function = fun(V) -> V end, 
> lasp:stream({<<"set">>, state_orset}, Function).