Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy widget #1400

Merged
merged 14 commits into from
Nov 3, 2022
Merged

Lazy widget #1400

merged 14 commits into from
Nov 3, 2022

Conversation

nicksenger
Copy link
Contributor

In some cases computations are performed in each view regardless of whether their inputs have actually changed. This PR adds a widget Cached, which takes some dependency and a function producing a view. The view function will only be invoked to generate a new element when the dependency produces a different hash.

The example displays a sorted list of items based on data stored in a set, and is optimized to only produce the sorted list when either the sort order or number of items in the list changes. The view function is not re-invoked in view after the user types into the text input, because the content of the input is not a dependency of the sorted list.

@hecrj hecrj added this to the 0.5.0 milestone Nov 3, 2022
@hecrj hecrj added feature New feature or request widget labels Nov 3, 2022
@hecrj hecrj marked this pull request as ready for review November 3, 2022 01:07
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Similar in spirit to the Html.lazy in Elm.

I renamed the widget to Lazy, since it's actually the main idea behind the iced_lazy crate!

@hecrj hecrj changed the title Add Cached widget Lazy widget Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request widget
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants