diff --git a/examples/workout/src/lib.rs b/examples/workout/src/lib.rs index 382bbd8..f9133cb 100644 --- a/examples/workout/src/lib.rs +++ b/examples/workout/src/lib.rs @@ -2,7 +2,8 @@ use hemplate::Hemplate; use hemx::{Html, IntoEffect}; use hemx_host::{ browser_pwa_host_profile, native_shell_host_profile, Capability, CapabilityManifest, - CapabilityShape, CapabilityUse, HapticPattern, HostCall, HostCallId, HostEvent, SharePayload, + CapabilityShape, CapabilityUse, HapticPattern, HostCall, HostCallId, HostEvent, + SharePayload as HostShareData, }; use std::collections::VecDeque; use std::sync::{Arc, Mutex}; @@ -315,7 +316,7 @@ pub fn export_log(app: &AppState) -> impl IntoEffect { )]); let call = HostCall::Share { id: HostCallId::new("workout-export"), - payload: SharePayload::text(state.event_log_text()), + payload: HostShareData::text(state.event_log_text()), }; state.host_status = match manifest.validate_call(&browser_pwa_host_profile(), &call) { Ok(()) => "Export requested through host share; waiting for host result.".into(), @@ -499,7 +500,7 @@ mod tests { assert!(html.contains("Complete set")); assert!(html.contains("Export via browser/PWA share")); assert!(html.contains("Request native haptic")); - assert!(!html.contains(", request: InteractionRequest, ) -> Result { - request.dispatch_async(registry(state)).await + request + .dispatch_async( + interactions(hemx_workout_example::ui::BUILD_FINGERPRINT) + .on(workout::complete_set, { + let state = state.clone(); + move |_| workout_app::complete_set(&state) + }) + .on(workout::change_weight, { + let state = state.clone(); + move |form| { + workout_app::change_weight(&state, form.parse::("kg").unwrap_or(0.0)) + } + }) + .on(workout::skip_exercise, { + let state = state.clone(); + move |_| workout_app::skip_exercise(&state) + }) + .on(workout::record_note, { + let state = state.clone(); + move |form| { + workout_app::record_note( + &state, + form.value("text").unwrap_or("").to_owned(), + ) + } + }) + .on(workout::export_log, { + let state = state.clone(); + move |_| workout_app::export_log(&state) + }) + .on(workout::record_share_result, { + let state = state.clone(); + move |_| workout_app::record_share_result(&state) + }) + .on(workout::request_native_haptic, { + let state = state.clone(); + move |_| workout_app::request_native_haptic(&state) + }) + .on(workout::record_native_haptic_ack, move |_| { + workout_app::record_native_haptic_ack(&state) + }), + ) + .await } async fn runtime() -> impl IntoResponse { runtime_js() } -fn registry(state: AppState) -> HandlerRegistry { - interactions(hemx_workout_example::ui::BUILD_FINGERPRINT) - .on(workout::complete_set, { - let state = state.clone(); - move |_| workout_app::complete_set(&state) - }) - .on(workout::change_weight, { - let state = state.clone(); - move |form| workout_app::change_weight(&state, form.parse::("kg").unwrap_or(0.0)) - }) - .on(workout::skip_exercise, { - let state = state.clone(); - move |_| workout_app::skip_exercise(&state) - }) - .on(workout::record_note, { - let state = state.clone(); - move |form| { - workout_app::record_note(&state, form.value("text").unwrap_or("").to_owned()) - } - }) - .on(workout::export_log, { - let state = state.clone(); - move |_| workout_app::export_log(&state) - }) - .on(workout::record_share_result, { - let state = state.clone(); - move |_| workout_app::record_share_result(&state) - }) - .on(workout::request_native_haptic, { - let state = state.clone(); - move |_| workout_app::request_native_haptic(&state) - }) - .on(workout::record_native_haptic_ack, move |_| { - workout_app::record_native_haptic_ack(&state) - }) -} - #[cfg(test)] mod tests { use super::*;