Forum Documentation Showcase Pricing Learn more

How to read an element's state?


#1

I’m having no trouble using instance.publishState to set the state, but how do I read the state from within my javascript? For instance, if the state were called ‘myState’ I know to set it with instance.publishState.myState and that’s working, but how exactly do I read the data of the current state? I’m currently setting a separate variable and reading that, but I’m sure there’s a more efficient way to do it.

A simple question, I’m sure, but I’ve looked through the documentation and searched the forum but I just can’t find it. Thanks for any help you can provide this newbie!


#2

You don’t read that back. Before writing it, clone it to instance.data:

Instance.data.myVariableProxy = whatevs

Now what u wrote to instance.publishstate(‘myVariable’, whatevs)… is available to you in a similar namespace.