Skip to content

Features expected for 1.0 version #136

@andreytkachenko

Description

@andreytkachenko

Hello, recently I have played with this framework and find it very interesting. I would be happy to use it. But right now it is not ready for real usage and here I'll will try to summarize all key features (fixes) expected for release version of the library.

1. Collections of Renderable of different type

Currently trait Renderable depends on component, but it is a huge limitation not allowing to create a collection of different kind of components and also not allowing to create nested components (Issue #128) (create container components like Tabs, Stacks, etc.), so ideally Renderable trait should looks like:

pub trait Renderable<CTX> {
    /// Called by rendering loop.
    fn view(&self) -> Html<CTX>;
}

Why is it possible?

Component is required only(AFAIK) for handling listeners (precisly for handle result type from listener callback) and for handling props changes. Those two things may be done in the component itself rather then in the library (or some how another way).

2. React syntax

A lot of people got used to use React syntax, and this library has to keep close to it as much as possible, so here is as example:

...
    fn view(&self) -> Html<CTX, Self> {
        html! {
            <div class="barrier",>
                <p>{ format!("{} on {} clicked", self.counter, self.limit) }</p>
                <Button: onsignal=|_| Msg::ChildClicked, title="Middle", />
            </div>
        }
    }
...

should looks like:

...
    fn view(&self) -> Html<CTX, Self> {
        html! {
            <div class="barrier">
                <p>{self.counter} on {self.limit} clicked</p>
                <misc::Button onsignal={|_| Msg::ChildClicked}>
                   Middle
                </misc::Button>
            </div>
        }
    }
...

Reacts componentDidMount analog

I think it will be good to exted Renderable trait:

pub trait Renderable<CTX> {
    /// Called by rendering loop.
    fn view(&self) -> Html<CTX>; // What about to rename this method to `render`
    /// Called after component mounted (updated) with all captured refs HashMap
    fn mount(&self, refs: HashMap<String, &Html<CTX>>) { // Or similar
        /// No default implementation
    }
}

Get rid of all confusing commas and semicolons

here are the issues #98, #127
I suspect it may be solved by a compiller plugin (as @deniskolodin mentioned in #127).

Allow raw text nodes

I don't see any limitations from rust to make it

html! {
    <p> Some raw text here</p>
    <p>{"Regular expression style if you need     special    formatting! Or smiles :)"}</p>
}

Components should be able to have a body

html! {
    <Tabs>
        <Tab>
            Some data here
        </Tab>
        ...
    </Tabs>
}

React's references to elements (virtual nodes)

html! {
   <div>
        <div ref="inner-data">Some data</div>
    </div>
}

3. Move virtual dom part into seporate crate

Why?

Because it would be great to use such react's style with different backends, like stdweb (for web) or GTK (for desktop). I suppose #108 may be easily solved by HTML rendering backend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions