We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1e1cab6 commit 844fc70Copy full SHA for 844fc70
guide/src/reference/attributes/on-js-imports/js_namespace.md
@@ -11,11 +11,16 @@ name (like a class or function name) it'll be accessed through this namespace.
11
extern "C" {
12
#[wasm_bindgen(js_namespace = console)]
13
fn log(s: &str);
14
+
15
+ type Foo;
16
+ #[wasm_bindgen(constructor, js_namespace = Bar]
17
+ fn new() -> Foo;
18
}
19
20
log("hello, console!");
21
+Foo::new();
22
```
23
-This is an example of how to bind `console.log` in Rust. The `log` function will
-be available in the Rust module and will be invoked as `console.log` in
24
+This is an example of how to bind namespaced items in Rust. The `log` and `Foo::new` functions will
25
+be available in the Rust module and will be invoked as `console.log` and `new Bar.Foo` in
26
JavaScript.
0 commit comments