How to read an element's state?

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!

1 Like

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.

3 Likes

But if you later change the state by other means, the one you stored in instance won’t be changed, right?