-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use runtime state? #18
Comments
To get iooxa running, are you using something like: <script async src="https://unpkg.com/@iooxa/article"></script> If so, there should be a global variable put onto the page (here), the interface that is provided for that variable is here. Try going to https://iooxa.dev, opening up the console - and there is an You should be able to create new variables using the The command const v = iooxa.createVariable('scope.name', 3); creates a new variable that does not have a DOM element, this is equivalent to: <r-scope name="scope">
<r-var name="name" value="3"></r-var>
</r-scope> Using the javascript API is lower level, and likely doesn't need to be used if you are scripting with the components, probably the best way is to use the HTML and then if you need access to the variable, use the Once you have the variable, you can update or get the value of it using: // Select it in the dom
const r = document.getElementById('id').$runtime;
// OR use iooxa to get it by name
const r = iooxa.getVariableByName('scope.name');
// Then you can get access to the variable value (or change the value etc.):
r.get(); Hopefully that helps a bit, happy to clarify or further explain. It might be helpful to explain your use case and I can maybe give some further pointers. |
Ok, I just noticed that the error is caused by the async inside the <script> tag. Without it, it works fine. |
Almost got to commenting on the The other thing that might help is that you can put an arbitrary function in the callbacks of sliders, etc. <script>
function hello(x, y) {
console.log(`The values of x and y is: ${x}, ${y}`)
}
</script>
<r-var name="x" value="20"></r-var>
<r-var name="y" value="40"></r-var>
<r-button dense :click="hello(x, y)"></r-button> |
Hi @rowanc1,
I have recently been working with iooxa again in more detail and have come across a few questions.
Most of all it is about the access to components. In your answer to #10 you finally mentioned two ways to manipulate component values:
The second option was the most suitable and intuitive for me in this case. I also tried to understand the first option, but was not even able to access the iooxa variable. You mentioned in the last release that iooxa is available in the window. Which modules do I have to import for this? And can you please explain what the command
const v = iooxa.createVariable('scope.name', 3);
does exactly? I thought at first that I would specify the variable from the html document in the argument of this function but that doesn't seem to be the case. But I do not create a new html element with it either. How does this help me when I try to manipulate the value of an iooxa html component?
Thanks a lot!
The text was updated successfully, but these errors were encountered: