B0ney

Results 6 comments of B0ney

If I recall, this was probably done because `web-sys` had a breaking change in one of its patch releases a few months back.

Rust's `bool` has a `then_some`/`then` method. This can be used with `on_press_maybe` to achieve the same thing: ```rust let enabled = false; button("hi").on_press_maybe(enabled.then_some(Message::Hi)); ```

Ah I see. While you can use variables to help reduce cognitive load in the latter example: ```rust let password_entered = !password.is_empty(); button("Login") .on_press_maybe(password_entered.then_some(Message::Login)) ``` I do think your proposed...

> > I do think your proposed method would definitely improve developer experience. Actually, I really like the explicit separation: > > > > ```rust > > button("Login") > >...

> This might not be the best solution because we would have to clone the option `self.on_press.clone()` every time we wanted to check if it was disabled or not. But...

> I think it's as simple as making `disabled_if` set `on_press` to `None` and the `is_disabled` flag to `true`, then ignore any future `on_press` calls if `is_disabled` is set. Yeah,...