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:
@@ -266,6 +266,10 @@ pub const fn handlers(fingerprint: BuildFingerprint) -> HandlerRegistry {
|
||||
HandlerRegistry::new(fingerprint)
|
||||
}
|
||||
|
||||
pub const fn interactions(fingerprint: BuildFingerprint) -> HandlerRegistry {
|
||||
HandlerRegistry::new(fingerprint)
|
||||
}
|
||||
|
||||
impl InteractionRequest {
|
||||
pub fn dispatch(
|
||||
self,
|
||||
@@ -320,6 +324,17 @@ impl HandlerRegistry {
|
||||
self.register(handle.id().id, handler)
|
||||
}
|
||||
|
||||
pub fn on<I, E>(
|
||||
self,
|
||||
handle: Handle<I>,
|
||||
handler: impl Fn(InteractionForm) -> E + Send + Sync + 'static,
|
||||
) -> Self
|
||||
where
|
||||
E: IntoEffect,
|
||||
{
|
||||
self.register_handle(handle, handler)
|
||||
}
|
||||
|
||||
pub fn dispatch(&self, form: InteractionForm) -> Result<EffectResponse, DispatchRejection> {
|
||||
let handle_id = form.handle_id;
|
||||
let Some(handler) = self.handlers.get(&handle_id) else {
|
||||
|
||||
Reference in New Issue
Block a user