Skip to content

How to create binding to object.object.function? (gapi.auth2.getAuthInstance) #3543

Closed Answered by Liamolucko
Miuler asked this question in Q&A
Discussion options

You must be logged in to vote

Assuming that gapi is a global variable, you can use js_namespace to do that:

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {
    type Auth2;

    #[wasm_bindgen(js_namespace = ["gapi", "auth2"], js_name = "getAuthInstance")]
    fn get_auth_instance() -> Auth2;
}

Calling get_auth_instance will then call gapi.auth2.getAuthInstance().

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Miuler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants