-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82cacab
commit 3153caf
Showing
10 changed files
with
50 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# Go to `www/README.md` | ||
|
||
--- | ||
|
||
<div align="center"> | ||
|
||
<h1><code>wasm-pack-template</code></h1> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
mod utils; | ||
|
||
use utils::set_panic_hook; | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
extern "C" { | ||
fn alert(s: &str); | ||
fn log(string: impl AsRef<str>) { | ||
web_sys::console::log_1(&JsValue::from_str(string.as_ref())); | ||
} | ||
|
||
#[wasm_bindgen] | ||
pub fn greet() { | ||
set_panic_hook(); | ||
alert("Hello, wasm_test_site!"); | ||
console_error_panic_hook::set_once(); | ||
|
||
log("Hello, wasm_test_site!"); | ||
} | ||
|
||
#[wasm_bindgen] | ||
pub fn test_hydroflow() -> web_sys::js_sys::Promise { | ||
console_error_panic_hook::set_once(); | ||
|
||
let mut df = hydroflow::hydroflow_syntax! { | ||
// https://hydro.run/docs/hydroflow/quickstart/example_1_simplest | ||
source_iter(0..10) -> for_each(|n| log(format!("Hello {}", n))); | ||
}; | ||
|
||
wasm_bindgen_futures::future_to_promise(async move { | ||
let work_done = df.run_available_async().await; | ||
Ok(if work_done { | ||
JsValue::TRUE | ||
} else { | ||
JsValue::FALSE | ||
}) | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import init, { greet } from "wasm_test_site"; | ||
import init, { greet, test_hydroflow } from "wasm_test_site"; | ||
let { memory } = await init(); | ||
greet(); | ||
test_hydroflow(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters