mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 20:41:24 +00:00
web-sys: Add support for Global
-scope methods
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 #659
This commit is contained in:
@ -40,11 +40,6 @@ pub struct Signature {
|
||||
pub email: String,
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
static window: Window;
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn run() -> Promise {
|
||||
let mut request_options = RequestInit::new();
|
||||
@ -56,7 +51,7 @@ pub fn run() -> Promise {
|
||||
// the RequestInit struct will eventually support setting headers, but that's missing right now
|
||||
req.headers().set("Accept", "application/vnd.github.v3+json").unwrap();
|
||||
|
||||
let req_promise = window.fetch_with_request(&req);
|
||||
let req_promise = Window::fetch_with_request(&req);
|
||||
|
||||
let to_return = JsFuture::from(req_promise).and_then(|resp_value| {
|
||||
// resp_value is a Response object
|
||||
|
Reference in New Issue
Block a user