feat(axum): add interaction registry alias

Add an interactions()/on() registration path and move canonical examples off explicit register_handle naming while keeping low-level registry types available underneath.

req: axum_integration/003

req: ceremony/001

req: dx/003

req: examples/003
This commit is contained in:
slhx agent
2026-06-02 00:24:32 +02:00
parent f388fa7d91
commit df4b4cc649
7 changed files with 41 additions and 25 deletions
+7 -7
View File
@@ -6,7 +6,7 @@ use futures_util::{stream, StreamExt};
use hemplate::Hemplate;
use slhx::{push, IntoEffect, RenderSlotExt, SafeHtml};
use slhx_axum::{
handlers, runtime_js, sse, DispatchRegistry, EffectResponse, InteractionRequest, PageRequest,
interactions, runtime_js, sse, DispatchRegistry, EffectResponse, InteractionRequest, PageRequest,
};
use slhx_v0_examples::ui;
use slhx_v0_examples::ui::{auth, counter, notifications, page_swap, todos, wizard};
@@ -124,8 +124,8 @@ async fn events(Query(params): Query<BTreeMap<String, String>>) -> impl IntoResp
}
fn registry(state: Arc<ExampleState>) -> impl DispatchRegistry {
handlers(ui::BUILD_FINGERPRINT)
.register_handle(counter_handles::increment, {
interactions(ui::BUILD_FINGERPRINT)
.on(counter_handles::increment, {
let state = state.clone();
move |_| {
// req: examples/001
@@ -134,7 +134,7 @@ fn registry(state: Arc<ExampleState>) -> impl DispatchRegistry {
counter_slots::counter_value.text(*counter)
}
})
.register_handle(todo_handles::add_todo, {
.on(todo_handles::add_todo, {
let state = state.clone();
move |form| {
// req: examples/001
@@ -150,7 +150,7 @@ fn registry(state: Arc<ExampleState>) -> impl DispatchRegistry {
)
}
})
.register_handle(wizard_handles::next_step, {
.on(wizard_handles::next_step, {
let state = state.clone();
move |_| {
// req: examples/001
@@ -159,7 +159,7 @@ fn registry(state: Arc<ExampleState>) -> impl DispatchRegistry {
wizard_slots::wizard_step.text(format!("Step {}", *step + 1))
}
})
.register_handle(auth_handles::login, |form| {
.on(auth_handles::login, |form| {
// req: examples/001
let ok = form.value("email") == Some("demo@example.com")
&& form.value("password").is_some_and(|password| !password.is_empty());
@@ -169,7 +169,7 @@ fn registry(state: Arc<ExampleState>) -> impl DispatchRegistry {
"Try demo@example.com with any password"
})
})
.register_handle(page_handles::load_docs, |_| {
.on(page_handles::load_docs, |_| {
// req: page_swap/002, req: examples/001
(
page_slots::content.render(&DocsContent {