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
Add support for invoking an init callback on component and element construction #1855
Conversation
internal/compiler/object_tree.rs
Outdated
@@ -677,6 +681,7 @@ impl Element { | |||
parent_type: ElementType, | |||
component_child_insertion_point: &mut Option<ChildrenInsertionPoint>, | |||
is_in_legacy_component: bool, | |||
is_component_root_element: bool, |
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.
I wonder if you can't get that from the parent_type
already
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.
I tried that, but I don't think that works for repeated/conditional elements, where the parent type is not None.
@@ -139,6 +139,11 @@ fn perform_binding_analysis( | |||
&(), | |||
&mut |e, _| analyze_element(e, &mut context, reverse_aliases, diag), | |||
); | |||
for expr in component.setup_code.borrow().iter() { |
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.
I don't think you need to visit the setup code here.
It can't be part of a binding loop anyway, and we don't collect stats for it.
125959d
to
d077de7
Compare
I've pushed a much simpler implementation that allows I'm uncertain if this is the right thing to do, or if it would be better to special-case this by producing a warning ("init deprecated, future blah blah") and excluding that callback from the initialisation code. Otherwise the TODO is:
|
Or a property "init" But i think it's fine. |
1226b79
to
89ca932
Compare
…nstruction This enables imperative code to be run. To be used sparingly :-)
f57b752
to
acad2d7
Compare
This enables imperative code to be run. To be used sparingly :-)