Implement closed typed effect path
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "hemx-server-wasm-test"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
hemplate = { version = "0.2.0", default-features = false, features = ["derive"] }
|
||||
hemx = { path = "../../hemx" }
|
||||
|
||||
[build-dependencies]
|
||||
hemx-build = { path = "../../hemx-build" }
|
||||
@@ -0,0 +1,6 @@
|
||||
fn main() {
|
||||
hemx_build::app()
|
||||
.template_dir("templates")
|
||||
.run()
|
||||
.expect("compile server-side Wasm surfaces");
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
use hemplate::Hemplate;
|
||||
use hemx::Effect;
|
||||
|
||||
#[hemx::surface]
|
||||
pub mod ui {}
|
||||
|
||||
#[derive(Hemplate)]
|
||||
pub struct Room {
|
||||
pub count: i32,
|
||||
}
|
||||
|
||||
#[derive(Hemplate)]
|
||||
pub struct CounterView {
|
||||
pub count: i32,
|
||||
}
|
||||
|
||||
pub fn render_page(count: i32) -> hemx::Html {
|
||||
ui::room::page(&Room { count })
|
||||
}
|
||||
|
||||
pub fn update_counter(count: i32) -> Effect {
|
||||
ui::room::put(ui::room::advanced::slots::counter, &CounterView { count })
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<strong>Count: {+ self.count +}</strong>
|
||||
@@ -0,0 +1,5 @@
|
||||
<main data-hemx-root="room">
|
||||
<section data-hemx-slot="counter">
|
||||
<strong>Count: {+ self.count +}</strong>
|
||||
</section>
|
||||
</main>
|
||||
Reference in New Issue
Block a user