feat(tazjin/presentations): add (intentionally) broken WASM demo
This demonstrates a Rust stdlib call that just causes runtime panics on WASM, for explaining the problems with porting Tvixbolt. Change-Id: Ief974f1bba509fdac4b9bc9f862ee8f4dfc5158e Reviewed-on: https://cl.tvl.fyi/c/depot/+/9206 Tested-by: BuildkiteCI Reviewed-by: Mark Shevchenko <markshevchenko@gmail.com> Autosubmit: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
0e01e91174
commit
4ef86040dd
5 changed files with 956 additions and 0 deletions
|
|
@ -0,0 +1,41 @@
|
|||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use yew::prelude::*;
|
||||
|
||||
fn time_example() -> Html {
|
||||
let epoch = match SystemTime::now().duration_since(UNIX_EPOCH) {
|
||||
Ok(duration) => duration.as_secs(),
|
||||
Err(err) => {
|
||||
return html! {
|
||||
format!("failed to calculate duration: {}", err)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
html! {
|
||||
<p>
|
||||
{"Seconds since epoch: "}{epoch}
|
||||
</p>
|
||||
}
|
||||
}
|
||||
|
||||
struct App;
|
||||
impl Component for App {
|
||||
type Message = ();
|
||||
type Properties = ();
|
||||
|
||||
fn create(_: &Context<Self>) -> Self {
|
||||
Self
|
||||
}
|
||||
|
||||
fn update(&mut self, _: &Context<Self>, _: Self::Message) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn view(&self, _: &Context<Self>) -> Html {
|
||||
time_example()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
yew::Renderer::<App>::new().render();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue