Skip to content

Commit

Permalink
xilem_web: Fix linebender#459, and add .boxed() combinator
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp-M committed Jul 28, 2024
1 parent 727d696 commit 3f9b651
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion xilem_web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ where
}

/// A view which can have any [`DomView`] type, see [`AnyView`] for more details.
pub type AnyDomView<State, Action = ()> = dyn AnyView<State, Action, ViewCtx, AnyPod>;
pub type AnyDomView<State, Action = ()> = dyn AnyView<State, Action, ViewCtx, AnyPod, DynMessage>;

/// The central [`View`] derived trait to represent DOM nodes in xilem_web, it's the base for all [`View`]s in xilem_web
pub trait DomView<State, Action = ()>:
Expand All @@ -97,6 +97,26 @@ pub trait DomView<State, Action = ()>:
type DomNode: DomNode<Self::Props>;
type Props;

/// Returns a boxed type erased [`AnyDomView`]
///
/// # Examples
/// ```
/// use xilem_web::{elements::html::div, DomView};
///
/// # fn view<State: 'static>() -> impl DomView<State> {
/// div("a label").boxed()
/// # }
///
/// ```
fn boxed(self) -> Box<AnyDomView<State, Action>>
where
State: 'static,
Action: 'static,
Self: Sized,
{
Box::new(self)
}

/// See [`adapt`](`core::adapt`)
fn adapt<ParentState, ParentAction, ProxyFn>(
self,
Expand Down

0 comments on commit 3f9b651

Please sign in to comment.