From 631326c79cc2db41e1da3fd4245ecb60606abc8a Mon Sep 17 00:00:00 2001 From: Andrii Zymohliad Date: Sun, 28 Jul 2024 21:29:08 +0300 Subject: [PATCH] Minor refactor --- xilem/src/view/message_handler.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xilem/src/view/message_handler.rs b/xilem/src/view/message_handler.rs index 7299421e6..3e50af3f8 100644 --- a/xilem/src/view/message_handler.rs +++ b/xilem/src/view/message_handler.rs @@ -26,7 +26,7 @@ pub fn message_handler( handle_event: H, ) -> MessageHandler where - F: Fn(&mut State, MessageProxy) + 'static, + F: Fn(&mut State, MessageProxy) -> Action + 'static, H: Fn(&mut State, M) -> Action + 'static, M: Message + 'static, { @@ -48,7 +48,7 @@ pub struct MessageHandler { impl View for MessageHandler where - F: Fn(&mut State, MessageProxy) + 'static, + F: Fn(&mut State, MessageProxy) -> Action + 'static, H: Fn(&mut State, M) -> Action + 'static, M: Message + 'static, { @@ -95,11 +95,12 @@ where ); if message.deref().as_any().is::() { let proxy = MessageProxy::new(raw_proxy.clone(), path.clone()); - (self.store_proxy)(app_state, proxy); - xilem_core::MessageResult::Nop + let action = (self.store_proxy)(app_state, proxy); + xilem_core::MessageResult::Action(action) } else { let message = message.downcast::().unwrap(); - xilem_core::MessageResult::Action((self.handle_event)(app_state, *message)) + let action = (self.handle_event)(app_state, *message); + xilem_core::MessageResult::Action(action) } } }