From e7ff4541a7d62e89bea4465da89dcef87f8428bd Mon Sep 17 00:00:00 2001 From: slhx agent Date: Fri, 12 Jun 2026 17:40:41 +0200 Subject: [PATCH] refactor(v0): name generated interaction handlers Expose and use InteractionHandlers in the beginner example so the normal path reads as app handlers instead of registry plumbing while preserving the integration registry API. req: ceremony/005 --- examples/v0/src/main.rs | 24 ++++++++++++------------ hemx-axum/src/lib.rs | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/v0/src/main.rs b/examples/v0/src/main.rs index 22ccc23..4f5558c 100644 --- a/examples/v0/src/main.rs +++ b/examples/v0/src/main.rs @@ -7,7 +7,7 @@ use hemplate::Hemplate; use hemx::{Html, IntoEffect}; use hemx_axum::{ interactions, runtime_js, runtime_js_path, sse, EffectResponse, Form, HandlerErrorContext, - HandlerFailure, InteractionRequest, IntoHandlerFailure, PageRequest, Registry, + HandlerFailure, InteractionHandlers, InteractionRequest, IntoHandlerFailure, PageRequest, }; use hemx_v0_examples::ui; use hemx_v0_examples::ui::{auth, counter, notifications, page_swap, todo_row, todos, wizard}; @@ -228,7 +228,7 @@ async fn interact( State(state): State>, request: InteractionRequest, ) -> Result { - request.dispatch_async(registry(state)).await + request.dispatch_async(handlers(state)).await } async fn runtime() -> impl IntoResponse { @@ -264,7 +264,7 @@ async fn events(Query(params): Query>) -> impl IntoResp wizard_handlers, auth_handlers )] -fn registry(state: Arc) -> Registry { +fn handlers(state: Arc) -> InteractionHandlers { interactions(ui::BUILD_FINGERPRINT) } @@ -665,7 +665,7 @@ mod tests { let counter = inspect_batch( InteractionRequest::from(form(counter::increment, &[])) - .dispatch_async(registry(state.clone())) + .dispatch_async(handlers(state.clone())) .await .unwrap() .batch, @@ -676,7 +676,7 @@ mod tests { let validation = inspect_batch( InteractionRequest::from(form(todos::add_todo, &[("title", " ")])) - .dispatch_async(registry(state.clone())) + .dispatch_async(handlers(state.clone())) .await .unwrap() .batch, @@ -686,7 +686,7 @@ mod tests { let store_failure = inspect_batch( InteractionRequest::from(form(todos::add_todo, &[("title", "fail-db")])) - .dispatch_async(registry(state.clone())) + .dispatch_async(handlers(state.clone())) .await .unwrap() .batch, @@ -697,7 +697,7 @@ mod tests { let add = inspect_batch( InteractionRequest::from(form(todos::add_todo, &[("title", "Ship v0")])) - .dispatch_async(registry(state.clone())) + .dispatch_async(handlers(state.clone())) .await .unwrap() .batch, @@ -715,7 +715,7 @@ mod tests { todo_row::rename_todo, &[("id", "1"), ("title", "Ship 1.0")], )) - .dispatch_async(registry(state.clone())) + .dispatch_async(handlers(state.clone())) .await .unwrap() .batch, @@ -727,7 +727,7 @@ mod tests { let delete = inspect_batch( InteractionRequest::from(form(todo_row::delete_todo, &[("id", "1")])) - .dispatch_async(registry(state.clone())) + .dispatch_async(handlers(state.clone())) .await .unwrap() .batch, @@ -740,7 +740,7 @@ mod tests { let missing_delete = inspect_batch( InteractionRequest::from(form(todo_row::delete_todo, &[("id", "99")])) - .dispatch_async(registry(state.clone())) + .dispatch_async(handlers(state.clone())) .await .unwrap() .batch, @@ -749,7 +749,7 @@ mod tests { let wizard = inspect_batch( InteractionRequest::from(form(wizard::next_step, &[("step", "1")])) - .dispatch_async(registry(state.clone())) + .dispatch_async(handlers(state.clone())) .await .unwrap() .batch, @@ -762,7 +762,7 @@ mod tests { auth::login, &[("email", "demo@example.com"), ("password", "secret")], )) - .dispatch_async(registry(state)) + .dispatch_async(handlers(state)) .await .unwrap() .batch, diff --git a/hemx-axum/src/lib.rs b/hemx-axum/src/lib.rs index 8ad37e4..ecba4f3 100644 --- a/hemx-axum/src/lib.rs +++ b/hemx-axum/src/lib.rs @@ -225,6 +225,7 @@ pub struct HandlerRegistry { } pub type Registry = HandlerRegistry; +pub type InteractionHandlers = HandlerRegistry; pub struct StateHandlerRegistry { registry: HandlerRegistry,