mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 20:41:24 +00:00
guide: Add JsValue
example to supported types section
This commit is contained in:
10
examples/guide-supported-types-examples/js_value.js
Normal file
10
examples/guide-supported-types-examples/js_value.js
Normal file
@ -0,0 +1,10 @@
|
||||
import {
|
||||
take_js_value_by_value,
|
||||
take_js_value_by_shared_ref,
|
||||
return_js_value,
|
||||
} from './guide_supported_types_examples';
|
||||
|
||||
take_js_value_by_value(42);
|
||||
take_js_value_by_shared_ref('hello');
|
||||
|
||||
let v = return_js_value();
|
12
examples/guide-supported-types-examples/src/js_value.rs
Normal file
12
examples/guide-supported-types-examples/src/js_value.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn take_js_value_by_value(x: JsValue) {}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn take_js_value_by_shared_ref(x: &JsValue) {}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn return_js_value() -> JsValue {
|
||||
JsValue::NULL
|
||||
}
|
@ -9,3 +9,4 @@ pub mod str;
|
||||
pub mod string;
|
||||
pub mod char;
|
||||
pub mod bool;
|
||||
pub mod js_value;
|
||||
|
Reference in New Issue
Block a user