feat: Add on_change input argument to SpinButton

This commit is contained in:
Michael Aaron Murphy 2022-12-07 03:44:57 +01:00
parent 3f88fb98e2
commit cb77ca1255
No known key found for this signature in database
GPG key ID: B2732D4240C9212C
3 changed files with 29 additions and 15 deletions

View file

@ -23,8 +23,11 @@ impl<T: 'static> SpinButtonModel<T>
where
T: Copy + Hash + ToString + Sub<Output = T> + Add<Output = T> + Ord,
{
pub fn view(&self) -> Element<'static, SpinMessage> {
SpinButton::new(self.value).into_element()
pub fn view<Message: 'static>(
&self,
on_change: impl Fn(SpinMessage) -> Message + 'static,
) -> Element<'static, Message> {
SpinButton::new(self.value, on_change).into_element()
}
pub fn update(&mut self, message: SpinMessage) {