diff --git a/examples/dashboard/src/lib.rs b/examples/dashboard/src/lib.rs index 0e0cfee3bd5..6cac152ff84 100644 --- a/examples/dashboard/src/lib.rs +++ b/examples/dashboard/src/lib.rs @@ -201,19 +201,19 @@ impl Component for Model { { self.view_data() } diff --git a/src/html/scope.rs b/src/html/scope.rs index 9ea5dd94527..f7f9818690b 100644 --- a/src/html/scope.rs +++ b/src/html/scope.rs @@ -108,10 +108,12 @@ impl Scope { } /// Send a message to the component - pub fn send_message(&self, msg: COMP::Message) { - self.update(ComponentUpdate::Message(msg)); + pub fn send_message(&self, msg: T) + where + T: Into, + { + self.update(ComponentUpdate::Message(msg.into())); } - /// Send a batch of messages to the component pub fn send_message_batch(&self, messages: Vec) { self.update(ComponentUpdate::MessageBatch(messages)); @@ -119,9 +121,10 @@ impl Scope { /// This method creates a `Callback` which will send a message to the linked component's /// update method when invoked. - pub fn callback(&self, function: F) -> Callback + pub fn callback(&self, function: F) -> Callback where - F: Fn(IN) -> COMP::Message + 'static, + M: Into, + F: Fn(IN) -> M + 'static, { let scope = self.clone(); let closure = move |input| { diff --git a/src/services/fetch/std_web.rs b/src/services/fetch/std_web.rs index 228ea8d7978..e9cb8070f13 100644 --- a/src/services/fetch/std_web.rs +++ b/src/services/fetch/std_web.rs @@ -291,10 +291,10 @@ impl FetchService { ///# fn update(&mut self, msg: Self::Message) -> bool {unimplemented!()} ///# fn view(&self) -> Html {unimplemented!()} ///# } - ///# pub enum Msg {} + ///# pub enum Msg { } ///# fn dont_execute() { ///# let link: ComponentLink = unimplemented!(); - ///# let callback = link.callback(|response: Response>| unimplemented!()); + ///# let callback = link.callback(|response: Response>| -> Msg { unimplemented!() }); /// let request = fetch::Request::get("/path/") /// .body(Nothing) /// .unwrap(); diff --git a/src/services/fetch/web_sys.rs b/src/services/fetch/web_sys.rs index 1c9b4f14ae0..c185320a6c6 100644 --- a/src/services/fetch/web_sys.rs +++ b/src/services/fetch/web_sys.rs @@ -298,7 +298,7 @@ impl FetchService { ///# pub enum Msg {} ///# fn dont_execute() { ///# let link: ComponentLink = unimplemented!(); - ///# let callback = link.callback(|response: Response>| unimplemented!()); + ///# let callback = link.callback(|response: Response>| -> Msg { unimplemented!() }); /// let request = fetch::Request::get("/path/") /// .body(Nothing) /// .unwrap();