Struct consecuit::construction::component::ComponentConstruction [−][src]
pub struct ComponentConstruction<CurrentStores: StoresList, EntireStores: StoresList, LastNode: MaybeHoleNode, ReturnNode: MaybeHoleNode> { /* fields omitted */ }
Expand description
This is the consecuit
or cc
object in your component function.
You can use it to call hooks and render other components.
See the doc at crate
on how to write components.
Implementations
impl<EntireStores> ComponentConstruction<StoreConsEnd, EntireStores, NoHoleNode, NoHoleNode> where
EntireStores: StoresList,
impl<EntireStores> ComponentConstruction<StoreConsEnd, EntireStores, NoHoleNode, NoHoleNode> where
EntireStores: StoresList,
pub fn bare_container_node(
self,
node: Node
) -> ComponentConstruction<StoreConsEnd, EntireStores, NoHoleNode, YesHoleNode>
pub fn bare_container_node(
self,
node: Node
) -> ComponentConstruction<StoreConsEnd, EntireStores, NoHoleNode, YesHoleNode>
Mark this component as a base container component.
This is for creating your own base component.
If you stick with the ones provided by the consecuit_html
crate, you won’t need this.
If you want to use this, use consecuit_html
’s source code as example.
pub fn bare_leaf_node(
self
) -> ComponentConstruction<StoreConsEnd, EntireStores, NoHoleNode, NoHoleNode>
pub fn bare_leaf_node(
self
) -> ComponentConstruction<StoreConsEnd, EntireStores, NoHoleNode, NoHoleNode>
Mark this component as a base leaf (childless) component.
This is for creating your own base component.
If you stick with the ones provided by the consecuit_html
crate, you won’t need this.
If you want to use this, use consecuit_html
’s source code as example.
impl<CurrentStores, EntireStores, LastNode, CompHole> ComponentConstruction<CurrentStores, EntireStores, LastNode, CompHole> where
CurrentStores: StoresList,
EntireStores: StoresList,
LastNode: MaybeHoleNode,
CompHole: MaybeHoleNode,
impl<CurrentStores, EntireStores, LastNode, CompHole> ComponentConstruction<CurrentStores, EntireStores, LastNode, CompHole> where
CurrentStores: StoresList,
EntireStores: StoresList,
LastNode: MaybeHoleNode,
CompHole: MaybeHoleNode,
Get the parent Node the current component should render on.
This is for creating your own base component.
If you stick with the ones provided by the consecuit_html
crate, you won’t need this.
If you want to use this, use consecuit_html
’s source code as example.
impl<CurrentStores, RestStores, EntireStores, LastNode, CompHole> ComponentConstruction<StoreCons<CurrentStores, RestStores>, EntireStores, LastNode, CompHole> where
CurrentStores: StoresList,
RestStores: StoresList,
EntireStores: StoresList,
LastNode: MaybeHoleNode,
CompHole: MaybeHoleNode,
impl<CurrentStores, RestStores, EntireStores, LastNode, CompHole> ComponentConstruction<StoreCons<CurrentStores, RestStores>, EntireStores, LastNode, CompHole> where
CurrentStores: StoresList,
RestStores: StoresList,
EntireStores: StoresList,
LastNode: MaybeHoleNode,
CompHole: MaybeHoleNode,
pub fn hook<Arg, Ret, Out>(
self,
hook_func: fn(_: HookBuilder, _: Arg) -> Ret,
hook_arg: Arg
) -> (ComponentConstruction<RestStores, EntireStores, LastNode, CompHole>, Out) where
Ret: HookReturn<Out, StoresList = CurrentStores>,
pub fn hook<Arg, Ret, Out>(
self,
hook_func: fn(_: HookBuilder, _: Arg) -> Ret,
hook_arg: Arg
) -> (ComponentConstruction<RestStores, EntireStores, LastNode, CompHole>, Out) where
Ret: HookReturn<Out, StoresList = CurrentStores>,
Use the given hook, with the given arg.
Consumes self
. Returns a tuple of (cc, <return value of hook>)
.
You can use the returned cc
to call more hooks.
See the docs at crate for more info on how to write and use hooks.
impl<RestStores, EntireStores, Ret, Props, LastNode, CompHole> ComponentConstruction<StoreCons<ComponentStoreInstance<Ret, Props>, RestStores>, EntireStores, LastNode, CompHole> where
RestStores: StoresList,
EntireStores: StoresList,
LastNode: MaybeHoleNode,
CompHole: MaybeHoleNode,
Ret: ComponentReturn,
Props: ComponentProps,
impl<RestStores, EntireStores, Ret, Props, LastNode, CompHole> ComponentConstruction<StoreCons<ComponentStoreInstance<Ret, Props>, RestStores>, EntireStores, LastNode, CompHole> where
RestStores: StoresList,
EntireStores: StoresList,
LastNode: MaybeHoleNode,
CompHole: MaybeHoleNode,
Ret: ComponentReturn,
Props: ComponentProps,
pub fn comp(
self,
component_func: ComponentFunc<Ret, Props>,
component_props: Props
) -> ComponentConstruction<RestStores, EntireStores, Ret::HoleNode, CompHole>
pub fn comp(
self,
component_func: ComponentFunc<Ret, Props>,
component_props: Props
) -> ComponentConstruction<RestStores, EntireStores, Ret::HoleNode, CompHole>
Render the given component with the given prop.
This consumes the consecuit
or cc
object, and returns a new one.
This is equivalent to a tag in the cc_tree!
macro.
For example:
cc_tree!( <div /> <footer {html_props().class_name("hi")} /> )
is equivalent to
cc.comp(div, Default::default()) .comp(footer, html_props().class_name("hi"))
impl<CurrentStores, RestStores, EntireStores, CompHole> ComponentConstruction<StoreCons<CurrentStores, RestStores>, EntireStores, YesHoleNode, CompHole> where
CurrentStores: StoresList,
RestStores: StoresList,
EntireStores: StoresList,
CompHole: MaybeHoleNode,
impl<CurrentStores, RestStores, EntireStores, CompHole> ComponentConstruction<StoreCons<CurrentStores, RestStores>, EntireStores, YesHoleNode, CompHole> where
CurrentStores: StoresList,
RestStores: StoresList,
EntireStores: StoresList,
CompHole: MaybeHoleNode,
pub fn child<Builder, ChildLastNode, ChildHole>(
self,
builder: Builder
) -> ComponentConstruction<RestStores, EntireStores, NoHoleNode, ChildHole> where
ChildHole: MaybeHoleNode,
ChildLastNode: MaybeHoleNode,
Builder: FnOnce(ComponentConstruction<CurrentStores, CurrentStores, NoHoleNode, CompHole>) -> ComponentConstruction<StoreConsEnd, CurrentStores, ChildLastNode, ChildHole>,
pub fn child<Builder, ChildLastNode, ChildHole>(
self,
builder: Builder
) -> ComponentConstruction<RestStores, EntireStores, NoHoleNode, ChildHole> where
ChildHole: MaybeHoleNode,
ChildLastNode: MaybeHoleNode,
Builder: FnOnce(ComponentConstruction<CurrentStores, CurrentStores, NoHoleNode, CompHole>) -> ComponentConstruction<StoreConsEnd, CurrentStores, ChildLastNode, ChildHole>,
Descend into the hole of the last component with the given closure.
This consumes the consecuit
or cc
object, and returns a new one.
Use this to nest components. For example:
cc.comp(table, html_props()) .child(|cc| { cc.comp(tr, html_props()) .child(|cc| { cc.comp(td, html_props()) .child(|cc| { cc.comp(text_node, "hello") }) }) })
The cc_tree!
macro equivalent for the above code is:
cc_tree!( <table {html_props()}> <tr {html_props()}> <td {html_props()}> "hello" </td> </tr> </table> )
Note that this only work on components that returns impl ContainerReturn
.
impl<Stores, EntireStores> ComponentConstruction<Stores, EntireStores, YesHoleNode, NoHoleNode> where
Stores: StoresList,
EntireStores: StoresList,
impl<Stores, EntireStores> ComponentConstruction<Stores, EntireStores, YesHoleNode, NoHoleNode> where
Stores: StoresList,
EntireStores: StoresList,
pub fn hole_here(
self
) -> ComponentConstruction<Stores, EntireStores, NoHoleNode, YesHoleNode>
pub fn hole_here(
self
) -> ComponentConstruction<Stores, EntireStores, NoHoleNode, YesHoleNode>
Mark the lastest comp as the Hole of this component.
Calling .child(...)
on this component will put the children there.
A component that returns impl ContainerReturn
must have exactly one .hole_here()
.
The cc_tree!
macro equivalent to this is the HOLE
attribute. Like
<div HOLE />
impl<RestStores, EntireStores, Props, LastNode, CompHole> ComponentConstruction<StoreCons<RefCell<Option<Box<dyn Subtree<Props = Props>>>>, RestStores>, EntireStores, LastNode, CompHole> where
RestStores: StoresList,
EntireStores: StoresList,
LastNode: MaybeHoleNode,
CompHole: MaybeHoleNode,
Props: ComponentProps,
impl<RestStores, EntireStores, Props, LastNode, CompHole> ComponentConstruction<StoreCons<RefCell<Option<Box<dyn Subtree<Props = Props>>>>, RestStores>, EntireStores, LastNode, CompHole> where
RestStores: StoresList,
EntireStores: StoresList,
LastNode: MaybeHoleNode,
CompHole: MaybeHoleNode,
Props: ComponentProps,
pub fn dyn_comp<Ret: ComponentReturn>(
self,
func: ComponentFunc<Ret, Props>,
props: Props
) -> ComponentConstruction<RestStores, EntireStores, NoHoleNode, CompHole>
pub fn dyn_comp<Ret: ComponentReturn>(
self,
func: ComponentFunc<Ret, Props>,
props: Props
) -> ComponentConstruction<RestStores, EntireStores, NoHoleNode, CompHole>
Like .comp(...)
, but mount the component in a dynamic subtree.
This hides the components’ typing from its parent.
You can use this to name a component’s return type concretely.
The task is a bit boilerplatey. Copy paste this code:
fn outer_comp(cc: ComponentBuilder, props: MyProp) -> DynComponentReturn<MyProp> { fn inner_comp(cc: ComponentBuilder, props: MyProp) -> impl ComponentReturn { cc_tree!( <div> "hello, I'm a dynamic component. My props is:" {props.to_string()} </div> ) } consecuit.dyn_comp(inner_comp, props) // inner_comp doesn't have to be an inner function. a closure works too. }
Then modify inner_comp
as you like.
Trait Implementations
impl<Stores: StoresList, LastNode: MaybeHoleNode, HoleNode: MaybeHoleNode> ComponentReturn for ComponentConstruction<StoreConsEnd, Stores, LastNode, HoleNode>
impl<Stores: StoresList, LastNode: MaybeHoleNode, HoleNode: MaybeHoleNode> ComponentReturn for ComponentConstruction<StoreConsEnd, Stores, LastNode, HoleNode>
Auto Trait Implementations
impl<CurrentStores, EntireStores, LastNode, ReturnNode> !RefUnwindSafe for ComponentConstruction<CurrentStores, EntireStores, LastNode, ReturnNode>
impl<CurrentStores, EntireStores, LastNode, ReturnNode> !Send for ComponentConstruction<CurrentStores, EntireStores, LastNode, ReturnNode>
impl<CurrentStores, EntireStores, LastNode, ReturnNode> !Sync for ComponentConstruction<CurrentStores, EntireStores, LastNode, ReturnNode>
impl<CurrentStores, EntireStores, LastNode, ReturnNode> Unpin for ComponentConstruction<CurrentStores, EntireStores, LastNode, ReturnNode> where
EntireStores: Unpin,
LastNode: Unpin,
ReturnNode: Unpin,
impl<CurrentStores, EntireStores, LastNode, ReturnNode> !UnwindSafe for ComponentConstruction<CurrentStores, EntireStores, LastNode, ReturnNode>