maciejhirsz / kobold

Easy declarative web interfaces.
https://docs.rs/kobold/
Mozilla Public License 2.0
385 stars 7 forks source link

refactor: refactor general #21

Closed ltfschoen closed 1 year ago

ltfschoen commented 1 year ago

@maciejhirsz how do you use the other functions mentioned in crates/kobold/js/utils.js?

for example start is in crates/kobold/js/utils.js and also in crates/kobold/src/lib.rs and then it's used in various examples main.rs files with kobold::start(html! { <Elapsed />})

so if i wanted to use fragment in crates/kobold/js/utils.js, is the idea just to add it to crates/kobold/src/lib.rs or in its own file in that folder, for example for fragement it'd just be

pub fn fragment() {
    init_panic_hook();

    util::__kobold_fragment();
}

before we can use it in an example main.rs file with kobold::fragment()?

but i can't see the purpose of fragement

maciejhirsz commented 1 year ago

before we can use it in an example main.rs file with kobold::fragment()?

but i can't see the purpose of fragement

There is a higher level RAII Fragment struct here:

https://github.com/maciejhirsz/kobold/blob/7fd98d2aec28c06b031efcae2e31405ca0683c9e/crates/kobold/src/dom.rs#L30-L51

All of those JS functions are just implementation details and shouldn't be exposed, the html! macro creates fragments just fine by default (no <>...</> needed).

maciejhirsz commented 1 year ago

Since there are no changes atm, I'll close it to keep the PRs clean.