From fcfca86a3604963c7bfbf06c28a3967f2fa0f56b Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov <3209180+agavrilov@users.noreply.github.com> Date: Fri, 30 Nov 2018 15:44:56 -0800 Subject: [PATCH] Add chainable variant of on_change --- src/views/radio.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/views/radio.rs b/src/views/radio.rs index 4c48e3c..03d3421 100644 --- a/src/views/radio.rs +++ b/src/views/radio.rs @@ -81,6 +81,15 @@ impl RadioGroup { ) { self.state.borrow_mut().on_change = Some(Rc::new(on_change)); } + + /// Sets a callback to be used when the selection changes. + /// + /// Chainable variant. + pub fn on_change( + self, on_change: F, + ) -> Self { + self.with(|s| s.set_on_change(on_change)) + } } impl RadioGroup { @@ -148,6 +157,7 @@ impl RadioButton { /// Chainable variant. pub fn selected(self) -> Self { self.with(|s| { + // Ignore the potential callback here s.select(); }) }