Skip to content

Commit

Permalink
Deprecate the component widget
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Sep 5, 2024
1 parent eada3b8 commit 9426418
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 159 deletions.
10 changes: 0 additions & 10 deletions examples/component/Cargo.toml

This file was deleted.

149 changes: 0 additions & 149 deletions examples/component/src/main.rs

This file was deleted.

1 change: 1 addition & 0 deletions widget/src/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub(crate) mod helpers;
pub mod component;
pub mod responsive;

#[allow(deprecated)]
pub use component::Component;
pub use responsive::Responsive;

Expand Down
6 changes: 6 additions & 0 deletions widget/src/lazy/component.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Build and reuse custom widgets using The Elm Architecture.
#![allow(deprecated)]
use crate::core::event;
use crate::core::layout::{self, Layout};
use crate::core::mouse;
Expand Down Expand Up @@ -31,6 +32,11 @@ use std::rc::Rc;
/// Additionally, a [`Component`] is capable of producing a `Message` to notify
/// the parent application of any relevant interactions.
#[cfg(feature = "lazy")]
#[deprecated(
since = "0.13.0",
note = "components introduce encapsulated state and hamper the use of a single source of truth. \
Instead, leverage the Elm Architecture directly, or implement a custom widget"
)]
pub trait Component<Message, Theme = crate::Theme, Renderer = crate::Renderer> {
/// The internal state of this [`Component`].
type State: Default;
Expand Down
7 changes: 7 additions & 0 deletions widget/src/lazy/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::lazy::component;

use std::hash::Hash;

#[allow(deprecated)]
pub use crate::lazy::{Component, Lazy, Responsive};

/// Creates a new [`Lazy`] widget with the given data `Dependency` and a
Expand All @@ -22,6 +23,12 @@ where
/// Turns an implementor of [`Component`] into an [`Element`] that can be
/// embedded in any application.
#[cfg(feature = "lazy")]
#[deprecated(
since = "0.13.0",
note = "components introduce encapsulated state and hamper the use of a single source of truth. \
Instead, leverage the Elm Architecture directly, or implement a custom widget"
)]
#[allow(deprecated)]
pub fn component<'a, C, Message, Theme, Renderer>(
component: C,
) -> Element<'a, Message, Theme, Renderer>
Expand Down

0 comments on commit 9426418

Please sign in to comment.