Skip to content
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

onParentChange callbacks #137

Open
raquo opened this issue Feb 11, 2023 · 3 comments
Open

onParentChange callbacks #137

raquo opened this issue Feb 11, 2023 · 3 comments

Comments

@raquo
Copy link
Owner

raquo commented Feb 11, 2023

Laminar elements can in theory be moved from one parent to another without unmounting. Few people knowingly use that feature, but it's possible, especially in Laminar 15.x.x. In those cases, certain advanced use cases (Frontroute URL routing, or integration with third party JS libs) might require notifications about such moves.

I think I can implement onBeforeParentChange and onAfterParentChange callbacks at no performance or complexity cost to users who don't need them. I'm not yet sure which one of those I will implement (feedback welcome). I do not plan to implement any other helper methods (*bind, *insert, etc.). I'm also not yet sure if these callbacks should fire on any parent change, or only if the element is mounted and remains mounted after the change.

Also, if the callback is to provide a reference to the next or previous parent, make sure this does not jeopardize GC – by the time the callback finishes, the reference to the old parent should be GC-d if it's not actually used, even if the callback spawned other closures (that also have access to the old parent reference, but don't use it). Figure out how to test for that.

Requested by @yurique

@raquo raquo added this to the v16.0.0 milestone Mar 8, 2023
@raquo raquo modified the milestones: v16.0.0, v17.0.0 Jul 8, 2023
@raquo
Copy link
Owner Author

raquo commented Jan 15, 2024

@yurique Sadly this won't make it to 17.x, too many other features.
What's your priority for this, compared to the other stuff I've been doing?
If you want, I can prioritize this for v18.

@yurique
Copy link
Sponsor Contributor

yurique commented Jan 15, 2024

@yurique Sadly this won't make it to 17.x, too many other features.

What's your priority for this, compared to the other stuff I've been doing?

If you want, I can prioritize this for v18.

No worries! I can barely remember what I wanted this for :). Definitely no rush with it.

@raquo
Copy link
Owner Author

raquo commented Jan 15, 2024

Ok cool, I'll keep applying the same prioritization logic for now then :)

@raquo raquo removed this from the v17.0.0 milestone Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants