-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Expose a getter for the global window #659
Comments
Currently the way to do this would look like: #[wasm_bindgen]
extern {
static window: Window;
}
// use `window` but importing via a |
Out of curiosity, why is using a |
Ah just a personal gut feeling! Using a |
Another benefit of using a function is that it's easier to search for in the docs |
We talked about this in the WG meeting today. We decided that when an interface has the This didn't come up at the meeting, but since there are multiple interfaces with |
This commit adds further support for the `Global` attribute to not only emit structural accessors but also emit functions that don't take `&self`. All methods on a `[Global]` interface will not require `&self` and will call functions and/or access properties on the global scope. This should enable things like: Window::location() // returns `Location` Window::fetch(...) // invokes the `fetch` function Closes rustwasm#659
This commit adds further support for the `Global` attribute to not only emit structural accessors but also emit functions that don't take `&self`. All methods on a `[Global]` interface will not require `&self` and will call functions and/or access properties on the global scope. This should enable things like: Window::location() // returns `Location` Window::fetch(...) // invokes the `fetch` function Closes rustwasm#659
I think we could do something like
inside
crates/web-sys/src/lib.rs
and consider that the entry point to all globally exposed properties and methods.The text was updated successfully, but these errors were encountered: