File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,14 @@ use wasm_bindgen::prelude::*;
22
33#[ wasm_bindgen]
44extern "C" {
5- fn js_callback ( msg : & str ) ;
5+ fn js_log ( msg : & str ) ;
6+ fn js_return_another_name ( ) -> String ;
67}
78
89#[ wasm_bindgen]
910pub fn greet ( name : & str ) -> String {
10- js_callback ( & format ! ( "Callback from Rust, says {name}." ) ) ;
11+ js_log ( & format ! ( "Callback from Rust, says {name}." ) ) ;
12+ let another_name = js_return_another_name ( ) ;
13+ js_log ( & format ! ( "Another callback from Rust, says {another_name}." ) ) ;
1114 format ! ( "Wasm works, says {name}." )
1215}
Original file line number Diff line number Diff line change 11import init , { greet } from "./pkg/wasm.js" ;
22
3- window . js_callback = ( msg ) => {
3+ window . js_log = ( msg ) => {
44 console . log ( "Called the callback from Rust:" , msg ) ;
55} ;
66
7+ window . js_return_another_name = ( ) => {
8+ return "Max" ;
9+ } ;
10+
711init ( ) . then ( ( ) => {
812 document . getElementById ( "out" ) . innerText = greet ( "Dima" ) ;
913} ) ;
You can’t perform that action at this time.
0 commit comments