Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new crate:
iced_lazy
.iced_lazy
is meant to contain types that are, in one way or another, related to laziness. A container widget is considered lazy when its contents are not strictly computed during anApplication::view
call. Instead, a lazy widget may choose the compute the contents beforehand, or only when necessary!Currently,
iced_lazy
only exposes a newComponent
trait:Basically, a
Component
can be viewed withview
, returning widgets that produce some specificEvent
. AComponent
can process anEvent
withupdate
, which may change its internal state and optionally return an applicationMessage
.In other words, a
Component
can be seen as a sub-application that follows The Elm Architecture, processing internal events and producing messages for the parent application when needed!The usefulness of this trait becomes apparent when we learn how to use it! The new
component::view
function has the following signature:Any
Component
implementor can be turned into anElement
! This means it is now possible to build custom widgets with its own internal mutable state by leveraging The Elm Architecture. These custom widgets can then be embedded in anyiced
application without additional wiring.The new
component
example uses this new trait to build aNumericInput
widget by leveraging composition of theButton
andTextInput
widgets.