-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change vdom bootstrapping to occur before the initial orders are processed. #235
Conversation
@AlterionX Your |
|
Oops, I forgot to force a render at the start. I was primarily doing testing with my own app, so I'll try to fix that now. |
So I've done a first round of code review:
I didn't dive deeper into code logic (e.g. why @AlterionX Well, it looks like I don't like the code but it's not true, I think it's very good and resolves many pains - my points are opinionated and the PR has many changes so it's a good opportunity to refactor it a little bit during process. |
All good points. I didn't even really think about it. Regarding Not sure if I should here, but I can try scanning over the entire library to see if there are some other things that can be pulled out? |
There are parts which don't make sense now or aren't super clean - don't be afraid to change it / create issue / write todo. (Just like every other project basically.)
I recommend to focus mostly on things which you are changing or are somehow related - just make it not too big for review and resolving conflicts with other PRs :) |
Got a question: is there a reason for the functions being put into the |
I'm not sure which functions do you mean (?). But in general - we try to write every public API with |
I'm referring to |
I think that there aren't any specific reasons. Why are you asking? |
I think if you make it generic, the compiler will complain that it can't figure out what the functions are actually supposed to be if you don't use, say, |
You can write them as type SinkFn<Ms, Mdl, ElC, GMs> = Box<dyn Fn(GMs, &mut Mdl, &mut OrdersContainer<Ms, Mdl, ElC, GMs>)>; (and compiled with one small change in code). |
Hrm, not exactly what I meant. I was wondering why trait SinkFn<Ms, Mdl, ElC, GMs>: FnMut(GMs, &mut Mdl, &mut OrdersContainer<Ms, Mdl, ElC, GMs>) {}
impl<Ms, Mdl, ElC, GMs, F> SinkFn for F
where
F: FnMut(GMs, &mut Mdl, &mut OrdersContainer<Ms, Mdl, ElC, GMs>) {} |
@MartinKavik @David-OConnor I'm starting to get half a mind to move the I think that this is better since we do this weird dance around So we would have App::build(update, view).finish().run_with_init(|_, _| {
// Do things with url + orders.
// `Init::default` is a wrapper for `Init::new(Model::default())`.
Init::default()
}) or App::build(update, view).finish().run() // Calls `Init::default` by default. It's a bit of a departure from what we currently have, but I think that it makes the implementation a little less weird and the usage clearer about when exactly the Personally, I also think that The downsides, I think, are also fairly obvious in that it's a breaking change, and so on. Also, the model is now provided in the I haven't seen if the types work out yet, but it seems reasonable to me. |
Whoops, didn't mean to do that. |
@MartinKavik I think it's ready for another go. Could you use the GitHub review stuff if you're going to make specific comments about specific function, please? It's easier to see what's being talked about that way. Also got a few comments/questions, by the way. I think I made/implemented the other suggestions.
Not entirely sure what method this is talking about. |
Closing to trigger another travis build -- I think it might be a Mac specific error, but it seemed to work just fine on linux. |
…d a thing to recursively strip workspace `Node`s from the enum.
… Implement `Init::default` for `Mdl`s that `impl Default`
@MartinKavik : Any objections to merging this? |
let mut new = El::empty(dom_types::Tag::Placeholder); | ||
|
||
// Map the DOM's elements onto the virtual DOM if requested to takeover. | ||
if bootstrap_behavior == Some(BootstrapBehavior::Takeover) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename it to mount_type
and MountType
so users don't have to relearn name once we change API to this one: #250 (comment)?
@David-OConnor I wrote some comments. It seems that the only public API change is |
I'm trying to pull out a few things from this PR into smaller PRs. Will fix the names and return types soon. |
Changes:
process_cmd_and_msg_queue
to after themain_el_vdom
is initialized. This allows for the msg processing to not cause issues if it attempts to force a render or something else similar. Forcing a render on init used to cause Seed to panic.takeover_mount
inAppBuilder
). Due to this behavior and backwards compatibility, it is currently an opt in functionality.Node
enum.web_sys::Node
s.Parts that need additional consideration (incomplete)
main_el_vdom
.Node
enum are actually of use.bootstrap_vdom
before this gets merged.