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
This commit is contained in:
slhx agent
2026-06-12 17:40:41 +02:00
parent 0f1673834b
commit e7ff4541a7
2 changed files with 13 additions and 12 deletions
+12 -12
View File
@@ -7,7 +7,7 @@ use hemplate::Hemplate;
use hemx::{Html, IntoEffect}; use hemx::{Html, IntoEffect};
use hemx_axum::{ use hemx_axum::{
interactions, runtime_js, runtime_js_path, sse, EffectResponse, Form, HandlerErrorContext, 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;
use hemx_v0_examples::ui::{auth, counter, notifications, page_swap, todo_row, todos, wizard}; use hemx_v0_examples::ui::{auth, counter, notifications, page_swap, todo_row, todos, wizard};
@@ -228,7 +228,7 @@ async fn interact(
State(state): State<Arc<ExampleState>>, State(state): State<Arc<ExampleState>>,
request: InteractionRequest, request: InteractionRequest,
) -> Result<EffectResponse, impl IntoResponse> { ) -> Result<EffectResponse, impl IntoResponse> {
request.dispatch_async(registry(state)).await request.dispatch_async(handlers(state)).await
} }
async fn runtime() -> impl IntoResponse { async fn runtime() -> impl IntoResponse {
@@ -264,7 +264,7 @@ async fn events(Query(params): Query<BTreeMap<String, String>>) -> impl IntoResp
wizard_handlers, wizard_handlers,
auth_handlers auth_handlers
)] )]
fn registry(state: Arc<ExampleState>) -> Registry { fn handlers(state: Arc<ExampleState>) -> InteractionHandlers {
interactions(ui::BUILD_FINGERPRINT) interactions(ui::BUILD_FINGERPRINT)
} }
@@ -665,7 +665,7 @@ mod tests {
let counter = inspect_batch( let counter = inspect_batch(
InteractionRequest::from(form(counter::increment, &[])) InteractionRequest::from(form(counter::increment, &[]))
.dispatch_async(registry(state.clone())) .dispatch_async(handlers(state.clone()))
.await .await
.unwrap() .unwrap()
.batch, .batch,
@@ -676,7 +676,7 @@ mod tests {
let validation = inspect_batch( let validation = inspect_batch(
InteractionRequest::from(form(todos::add_todo, &[("title", " ")])) InteractionRequest::from(form(todos::add_todo, &[("title", " ")]))
.dispatch_async(registry(state.clone())) .dispatch_async(handlers(state.clone()))
.await .await
.unwrap() .unwrap()
.batch, .batch,
@@ -686,7 +686,7 @@ mod tests {
let store_failure = inspect_batch( let store_failure = inspect_batch(
InteractionRequest::from(form(todos::add_todo, &[("title", "fail-db")])) InteractionRequest::from(form(todos::add_todo, &[("title", "fail-db")]))
.dispatch_async(registry(state.clone())) .dispatch_async(handlers(state.clone()))
.await .await
.unwrap() .unwrap()
.batch, .batch,
@@ -697,7 +697,7 @@ mod tests {
let add = inspect_batch( let add = inspect_batch(
InteractionRequest::from(form(todos::add_todo, &[("title", "Ship v0")])) InteractionRequest::from(form(todos::add_todo, &[("title", "Ship v0")]))
.dispatch_async(registry(state.clone())) .dispatch_async(handlers(state.clone()))
.await .await
.unwrap() .unwrap()
.batch, .batch,
@@ -715,7 +715,7 @@ mod tests {
todo_row::rename_todo, todo_row::rename_todo,
&[("id", "1"), ("title", "Ship 1.0")], &[("id", "1"), ("title", "Ship 1.0")],
)) ))
.dispatch_async(registry(state.clone())) .dispatch_async(handlers(state.clone()))
.await .await
.unwrap() .unwrap()
.batch, .batch,
@@ -727,7 +727,7 @@ mod tests {
let delete = inspect_batch( let delete = inspect_batch(
InteractionRequest::from(form(todo_row::delete_todo, &[("id", "1")])) InteractionRequest::from(form(todo_row::delete_todo, &[("id", "1")]))
.dispatch_async(registry(state.clone())) .dispatch_async(handlers(state.clone()))
.await .await
.unwrap() .unwrap()
.batch, .batch,
@@ -740,7 +740,7 @@ mod tests {
let missing_delete = inspect_batch( let missing_delete = inspect_batch(
InteractionRequest::from(form(todo_row::delete_todo, &[("id", "99")])) InteractionRequest::from(form(todo_row::delete_todo, &[("id", "99")]))
.dispatch_async(registry(state.clone())) .dispatch_async(handlers(state.clone()))
.await .await
.unwrap() .unwrap()
.batch, .batch,
@@ -749,7 +749,7 @@ mod tests {
let wizard = inspect_batch( let wizard = inspect_batch(
InteractionRequest::from(form(wizard::next_step, &[("step", "1")])) InteractionRequest::from(form(wizard::next_step, &[("step", "1")]))
.dispatch_async(registry(state.clone())) .dispatch_async(handlers(state.clone()))
.await .await
.unwrap() .unwrap()
.batch, .batch,
@@ -762,7 +762,7 @@ mod tests {
auth::login, auth::login,
&[("email", "demo@example.com"), ("password", "secret")], &[("email", "demo@example.com"), ("password", "secret")],
)) ))
.dispatch_async(registry(state)) .dispatch_async(handlers(state))
.await .await
.unwrap() .unwrap()
.batch, .batch,
+1
View File
@@ -225,6 +225,7 @@ pub struct HandlerRegistry {
} }
pub type Registry = HandlerRegistry; pub type Registry = HandlerRegistry;
pub type InteractionHandlers = HandlerRegistry;
pub struct StateHandlerRegistry<S> { pub struct StateHandlerRegistry<S> {
registry: HandlerRegistry, registry: HandlerRegistry,