Skip to content

No direct way to set ruby function/variables within javascript. #596

Description

@Drago-Cuven

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.

Activity

  1. kateinoigakukun commented on May 17, 2025

    @kateinoigakukun
    Member

    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!

  2. Drago-Cuven commented on May 17, 2025

    @Drago-Cuven
    Author

    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

  3. Drago-Cuven commented on May 24, 2025

    @Drago-Cuven
    Author
  4. Drago-Cuven commented on Sep 2, 2025

    @Drago-Cuven
    Author

    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!

    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.

  5. kateinoigakukun commented on Sep 3, 2025

    @kateinoigakukun
    Member

    I'll try my best to find time to take a look at this this week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions