feat(axum): add concise interaction request dispatch
Wrap extracted interaction forms in an InteractionRequest with a concise dispatch path, add a handlers() helper, and move canonical examples off direct HandlerRegistry/InteractionForm plumbing. req: axum_integration/003 req: ceremony/001 req: dx/003 req: examples/003
This commit is contained in:
@@ -5,7 +5,10 @@ use axum::Router;
|
||||
use futures_util::{stream, StreamExt};
|
||||
use hemplate::Hemplate;
|
||||
use slhx::{IntoEffect, RenderSlotExt, SafeHtml};
|
||||
use slhx_axum::{runtime_js, sse, DispatchRejection, EffectResponse, HandlerRegistry, InteractionForm, PageRequest};
|
||||
use slhx_axum::{
|
||||
handlers, runtime_js, sse, DispatchRegistry, DispatchRejection, EffectResponse,
|
||||
InteractionRequest, PageRequest,
|
||||
};
|
||||
use slhx_kanban_example::ui::{self, board as board_ui};
|
||||
use slhx_kanban_example::ui::board::{forms, handles, slots};
|
||||
use slhx_kanban_example::ui::board_card::handles as card_handles;
|
||||
@@ -127,9 +130,9 @@ async fn runtime() -> impl IntoResponse {
|
||||
|
||||
async fn interact(
|
||||
State(state): State<Arc<AppState>>,
|
||||
form: InteractionForm,
|
||||
request: InteractionRequest,
|
||||
) -> Result<EffectResponse, DispatchRejection> {
|
||||
registry(state).dispatch(form)
|
||||
request.dispatch(registry(state))
|
||||
}
|
||||
|
||||
// req: push/001 req: push/003 req: examples/001
|
||||
@@ -148,8 +151,8 @@ async fn events(Query(params): Query<BTreeMap<String, String>>) -> impl IntoResp
|
||||
sse(batches)
|
||||
}
|
||||
|
||||
fn registry(state: Arc<AppState>) -> HandlerRegistry {
|
||||
HandlerRegistry::new(ui::BUILD_FINGERPRINT)
|
||||
fn registry(state: Arc<AppState>) -> impl DispatchRegistry {
|
||||
handlers(ui::BUILD_FINGERPRINT)
|
||||
.register_handle(handles::create_card, {
|
||||
let state = state.clone();
|
||||
move |form| {
|
||||
|
||||
@@ -6,8 +6,8 @@ use futures_util::{stream, StreamExt};
|
||||
use hemplate::Hemplate;
|
||||
use slhx::{CssClass, CssClasses, IntoEffect, RenderSlotExt, SafeHtml};
|
||||
use slhx_axum::{
|
||||
runtime_js, sse, DispatchRejection, EffectResponse, HandlerRegistry, InteractionForm,
|
||||
PageRequest,
|
||||
handlers, runtime_js, sse, DispatchRegistry, DispatchRejection, EffectResponse,
|
||||
InteractionRequest, PageRequest,
|
||||
};
|
||||
use slhx_techdemo::ui;
|
||||
use slhx_techdemo::ui::control_center::{classes, forms, handles, slots};
|
||||
@@ -261,9 +261,9 @@ async fn island_js() -> impl IntoResponse {
|
||||
|
||||
async fn interact(
|
||||
State(state): State<Arc<Shared>>,
|
||||
form: InteractionForm,
|
||||
request: InteractionRequest,
|
||||
) -> Result<EffectResponse, DispatchRejection> {
|
||||
registry(state).dispatch(form)
|
||||
request.dispatch(registry(state))
|
||||
}
|
||||
|
||||
// req: push/001 req: push/003 req: examples/001
|
||||
@@ -282,8 +282,8 @@ async fn events(Query(params): Query<BTreeMap<String, String>>) -> impl IntoResp
|
||||
sse(batches)
|
||||
}
|
||||
|
||||
fn registry(shared: Arc<Shared>) -> HandlerRegistry {
|
||||
HandlerRegistry::new(ui::BUILD_FINGERPRINT)
|
||||
fn registry(shared: Arc<Shared>) -> impl DispatchRegistry {
|
||||
handlers(ui::BUILD_FINGERPRINT)
|
||||
.register_handle(handles::launch_work, {
|
||||
let shared = shared.clone();
|
||||
move |form| {
|
||||
|
||||
@@ -5,7 +5,9 @@ use axum::Router;
|
||||
use futures_util::{stream, StreamExt};
|
||||
use hemplate::Hemplate;
|
||||
use slhx::{push, IntoEffect, RenderSlotExt, SafeHtml};
|
||||
use slhx_axum::{runtime_js, sse, EffectResponse, HandlerRegistry, InteractionForm, PageRequest};
|
||||
use slhx_axum::{
|
||||
handlers, runtime_js, sse, DispatchRegistry, EffectResponse, InteractionRequest, PageRequest,
|
||||
};
|
||||
use slhx_v0_examples::ui;
|
||||
use slhx_v0_examples::ui::{auth, counter, notifications, page_swap, todos, wizard};
|
||||
use slhx_v0_examples::ui::auth::{handles as auth_handles, slots as auth_slots};
|
||||
@@ -96,9 +98,9 @@ async fn docs(request: PageRequest) -> impl IntoResponse {
|
||||
|
||||
async fn interact(
|
||||
State(state): State<Arc<ExampleState>>,
|
||||
form: InteractionForm,
|
||||
request: InteractionRequest,
|
||||
) -> Result<EffectResponse, impl IntoResponse> {
|
||||
registry(state).dispatch(form)
|
||||
request.dispatch(registry(state))
|
||||
}
|
||||
|
||||
async fn runtime() -> impl IntoResponse {
|
||||
@@ -121,8 +123,8 @@ async fn events(Query(params): Query<BTreeMap<String, String>>) -> impl IntoResp
|
||||
sse(batches)
|
||||
}
|
||||
|
||||
fn registry(state: Arc<ExampleState>) -> HandlerRegistry {
|
||||
HandlerRegistry::new(ui::BUILD_FINGERPRINT)
|
||||
fn registry(state: Arc<ExampleState>) -> impl DispatchRegistry {
|
||||
handlers(ui::BUILD_FINGERPRINT)
|
||||
.register_handle(counter_handles::increment, {
|
||||
let state = state.clone();
|
||||
move |_| {
|
||||
|
||||
Reference in New Issue
Block a user