Skip to content

Add on_press_with method for Button#2502

Merged
hecrj merged 1 commit intomasterfrom
button-on-press-with
Jul 12, 2024
Merged

Add on_press_with method for Button#2502
hecrj merged 1 commit intomasterfrom
button-on-press-with

Conversation

@hecrj
Copy link
Member

@hecrj hecrj commented Jul 12, 2024

This allows using a closure to produce the message only when the Button is actually pressed. Useful when generating the message may be expensive.

@hecrj hecrj added feature New feature or request widget addition labels Jul 12, 2024
@hecrj hecrj added this to the 0.13 milestone Jul 12, 2024
This allows using a closure to produce the message
only when the `Button` is actually pressed. Useful
when generating the message may be expensive.
@hecrj hecrj force-pushed the button-on-press-with branch from 3a772e7 to 97e35f7 Compare July 12, 2024 10:10
@hecrj hecrj enabled auto-merge July 12, 2024 10:12
@hecrj hecrj merged commit 65ea5fa into master Jul 12, 2024
@hecrj hecrj deleted the button-on-press-with branch July 12, 2024 10:21
@nrjais
Copy link
Contributor

nrjais commented Jul 12, 2024

I think this can help with relaxing the clone requirement on the Message, If the current on_press take a message that is cloneable and uses closure to clone it on demand.

@hecrj
Copy link
Member Author

hecrj commented Jul 12, 2024

I don't see the point in adding an unnecessary heap allocation. Messages should be cloneable and other widgets demand that bound as well, like TextInput.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition feature New feature or request widget

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments