You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No direct way to set ruby function/variables within javascript. #596
Looking through the docs, I expected to be able to find a way to directly set a variable and/or function to ruby in javascript using something like vm.set() like some high quality vms like pypy and wasmoon do but seeing that isnt the case that leavs me wondering how exactly can i do so? This features is pretty important for my project seeing as its how i need this to set a library of commands up to work.
To help us better understand your needs, could you share what kind of API or interface you would ideally like to see for setting Ruby variables or functions from JavaScript?
Thanks!
Ok, sorry for being so vague. I know that ruby doesn't exactly have functions, but methods in ruby are pretty close either way. i'm hoping that we can set variables and methods from ruby to variables and functions from javascript simar to the way the pypy and wasmoon VMs APIs work. In wasmoon you can see a direct example right there in the readme: "lua.global.set('sum', (x, y) => x + y)" i can imagine ruby.wasm's api working similarly with something like "vm.set('sum', (x, y) => x + y)" or "vm.setMethod('sum', (x, y) => x + y)" where set is just used for setting a variable from js. vm.get would obviously work in reverse.
Just in case you need context for what i'm trying to use these features for, here is a link to my repository.
To help us better understand your needs, could you share what kind of API or interface you would ideally like to see for setting Ruby variables or functions from JavaScript? Thanks!
sorry for being so clueless back then. i know it'd be difficult to create but i'd still think it'd be useful to add some sort of setMethod function to redirect a Method to instead run a JavaScript Function. its simple, its quick, and saves a lot of trouble.
Activity
kateinoigakukun commentedon May 17, 2025
Hi @Drago-Cuven, thanks for opening this issue!
To help us better understand your needs, could you share what kind of API or interface you would ideally like to see for setting Ruby variables or functions from JavaScript?
Thanks!
Drago-Cuven commentedon May 17, 2025
Ok, sorry for being so vague. I know that ruby doesn't exactly have functions, but methods in ruby are pretty close either way. i'm hoping that we can set variables and methods from ruby to variables and functions from javascript simar to the way the pypy and wasmoon VMs APIs work. In wasmoon you can see a direct example right there in the readme: "lua.global.set('sum', (x, y) => x + y)" i can imagine ruby.wasm's api working similarly with something like "vm.set('sum', (x, y) => x + y)" or "vm.setMethod('sum', (x, y) => x + y)" where set is just used for setting a variable from js. vm.get would obviously work in reverse.
Just in case you need context for what i'm trying to use these features for, here is a link to my repository.
https://github.com/Drago-Cuven/Dragonian-Extensions/tree/main/Written-Code-4-Scratch-Mods
Drago-Cuven commentedon May 24, 2025
@kateinoigakukun ?
Drago-Cuven commentedon Sep 2, 2025
sorry for being so clueless back then. i know it'd be difficult to create but i'd still think it'd be useful to add some sort of setMethod function to redirect a Method to instead run a JavaScript Function. its simple, its quick, and saves a lot of trouble.
kateinoigakukun commentedon Sep 3, 2025
I'll try my best to find time to take a look at this this week