fix(examples): lower slot render updates
Use generated lower-aware render paths before slot HTML updates so example fragments carry runtime ids for follow-up interactions such as browser drag/drop. req: component/003 req: runtime/001 req: examples/003
This commit is contained in:
@@ -4,7 +4,7 @@ use axum::routing::get;
|
||||
use axum::Router;
|
||||
use futures_util::{stream, StreamExt};
|
||||
use hemplate::Hemplate;
|
||||
use slhx::{IntoEffect, RenderSlotExt, SafeHtml};
|
||||
use slhx::{IntoEffect, SafeHtml};
|
||||
use slhx_axum::{
|
||||
interactions, runtime_js, sse, DispatchRegistry, DispatchRejection, EffectResponse,
|
||||
InteractionRequest, PageRequest,
|
||||
@@ -138,13 +138,13 @@ async fn interact(
|
||||
// req: push/001 req: push/003 req: examples/001
|
||||
async fn events(Query(params): Query<BTreeMap<String, String>>) -> impl IntoResponse {
|
||||
if params.contains_key("once") {
|
||||
let effect = slots::presence.render(&Presence { count: 1 });
|
||||
let effect = slots::presence.html(ui::render(&Presence { count: 1 }));
|
||||
return sse(stream::iter([Ok::<_, Infallible>(effect.into_batch(ui::BUILD_FINGERPRINT))]).boxed());
|
||||
}
|
||||
|
||||
let batches = stream::unfold(1_u64, |count| async move {
|
||||
tokio::time::sleep(Duration::from_secs(4)).await;
|
||||
let effect = slots::presence.render(&Presence { count });
|
||||
let effect = slots::presence.html(ui::render(&Presence { count }));
|
||||
Some((Ok::<_, Infallible>(effect.into_batch(ui::BUILD_FINGERPRINT)), count + 1))
|
||||
})
|
||||
.boxed();
|
||||
@@ -206,7 +206,7 @@ fn registry(state: Arc<AppState>) -> impl DispatchRegistry {
|
||||
|
||||
fn board_effects(board: &BoardState, notice: &'static str) -> impl IntoEffect {
|
||||
(
|
||||
slots::board.render(&board_view(board)),
|
||||
slots::board.html(ui::render(&board_view(board))),
|
||||
slots::notice.text(notice),
|
||||
forms::create_card.clear("title"),
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ use axum::routing::get;
|
||||
use axum::Router;
|
||||
use futures_util::{stream, StreamExt};
|
||||
use hemplate::Hemplate;
|
||||
use slhx::{CssClass, CssClasses, IntoEffect, RenderSlotExt, SafeHtml};
|
||||
use slhx::{CssClass, CssClasses, IntoEffect, SafeHtml};
|
||||
use slhx_axum::{
|
||||
interactions, runtime_js, sse, DispatchRegistry, DispatchRejection, EffectResponse,
|
||||
InteractionRequest, PageRequest,
|
||||
@@ -269,13 +269,13 @@ async fn interact(
|
||||
// req: push/001 req: push/003 req: examples/001
|
||||
async fn events(Query(params): Query<BTreeMap<String, String>>) -> impl IntoResponse {
|
||||
if params.contains_key("once") {
|
||||
let effect = slots::live_feed.render(&LiveFeed { tick: 1 });
|
||||
let effect = slots::live_feed.html(ui::render(&LiveFeed { tick: 1 }));
|
||||
return sse(stream::iter([Ok::<_, Infallible>(effect.into_batch(ui::BUILD_FINGERPRINT))]).boxed());
|
||||
}
|
||||
|
||||
let batches = stream::unfold(1_u64, |tick| async move {
|
||||
tokio::time::sleep(Duration::from_secs(4)).await;
|
||||
let effect = slots::live_feed.render(&LiveFeed { tick });
|
||||
let effect = slots::live_feed.html(ui::render(&LiveFeed { tick }));
|
||||
Some((Ok::<_, Infallible>(effect.into_batch(ui::BUILD_FINGERPRINT)), tick + 1))
|
||||
})
|
||||
.boxed();
|
||||
@@ -384,10 +384,10 @@ fn registry(shared: Arc<Shared>) -> impl DispatchRegistry {
|
||||
let mut demo = shared.demo.lock().unwrap();
|
||||
demo.log("Simulated push event produced the same EffectBatch shape");
|
||||
(
|
||||
slots::live_feed.render(&LiveFeed {
|
||||
slots::live_feed.html(ui::render(&LiveFeed {
|
||||
tick: demo.activity.len() as u64,
|
||||
}),
|
||||
slots::activity.render(&activity_view(&demo)),
|
||||
})),
|
||||
slots::activity.html(ui::render(&activity_view(&demo))),
|
||||
slots::notice.text("Push simulated · no client app code"),
|
||||
slhx::event("slhx:island-orbit", island_snapshot(&demo)),
|
||||
)
|
||||
@@ -414,10 +414,10 @@ fn update_work(demo: &mut DemoState, id: Option<u64>, update: impl FnOnce(&mut W
|
||||
|
||||
fn demo_effects(demo: &DemoState, notice: &'static str) -> impl IntoEffect {
|
||||
(
|
||||
slots::hero_metrics.render(&hero_view(demo)),
|
||||
slots::board.render(&board_view(demo)),
|
||||
slots::activity.render(&activity_view(demo)),
|
||||
slots::inspector.render(&inspector_view(demo)),
|
||||
slots::hero_metrics.html(ui::render(&hero_view(demo))),
|
||||
slots::board.html(ui::render(&board_view(demo))),
|
||||
slots::activity.html(ui::render(&activity_view(demo))),
|
||||
slots::inspector.html(ui::render(&inspector_view(demo))),
|
||||
slots::notice.text(notice),
|
||||
forms::launch_work.clear("title"),
|
||||
slhx::event("slhx:island-orbit", island_snapshot(demo)),
|
||||
|
||||
@@ -4,7 +4,7 @@ use axum::routing::get;
|
||||
use axum::Router;
|
||||
use futures_util::{stream, StreamExt};
|
||||
use hemplate::Hemplate;
|
||||
use slhx::{push, IntoEffect, RenderSlotExt, SafeHtml};
|
||||
use slhx::{push, IntoEffect, SafeHtml};
|
||||
use slhx_axum::{
|
||||
interactions, runtime_js, sse, DispatchRegistry, EffectResponse, InteractionRequest, PageRequest,
|
||||
};
|
||||
@@ -145,7 +145,7 @@ fn registry(state: Arc<ExampleState>) -> impl DispatchRegistry {
|
||||
todos.push(Todo { id, title: title.into() });
|
||||
}
|
||||
(
|
||||
todo_slots::todo_list.render(&todos_view(&todos)),
|
||||
todo_slots::todo_list.html(ui::render(&todos_view(&todos))),
|
||||
todo_forms::new_todo.clear("title"),
|
||||
)
|
||||
}
|
||||
@@ -172,9 +172,9 @@ fn registry(state: Arc<ExampleState>) -> impl DispatchRegistry {
|
||||
.on(page_handles::load_docs, |_| {
|
||||
// req: page_swap/002, req: examples/001
|
||||
(
|
||||
page_slots::content.render(&DocsContent {
|
||||
page_slots::content.html(ui::render(&DocsContent {
|
||||
message: "This content came from an EffectBatch.",
|
||||
}),
|
||||
})),
|
||||
page_slots::title.text("Docs"),
|
||||
push("/docs"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user