Skip to content
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

When I try to call a javascript function from rust. It does not work #869

Open
kiyingitimo opened this issue Dec 25, 2024 · 0 comments
Open

Comments

@kiyingitimo
Copy link

This is my js code

import { createApp } from 'vue'
import App from './App.vue'

function on_init() {
    console.log("Ready")
}


register_plugin = function (importObject) {
    importObject.env.perform_demo = function () {
        console.log("Called from rust")
    };
}

miniquad_add_plugin({ register_plugin, on_init });

createApp(App).mount('#app')

It's supposed to register a function to be called by Rust later on in this code

extern "C" {
    fn perform_demo();
}

#[macroquad::main("Coder")]
async fn main() {
    unsafe {
        perform_demo();
    }

It continues to give this in the console
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant