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

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.

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.

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.

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.

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"))

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.

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 />

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.