-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Introduce stable component api for custom components #213
Comments
Couldn't you do that like this? <script>
export default {
onrender () {
this.originalTitle = document.title;
this.observe( 'title', title => document.title = title );
},
onteardown () {
document.title = this.originalTitle;
}
};
</script> (It's a rhetorical question – you absolutely can do it that way – I'm more asking what the difference would be, other than perhaps skipping fragment generation.) |
I can think of two reasons (because sleep has wiped away the 3rd) why we should have a stable public component api:
|
I'm worried that it leads you into a bit of an uncanny valley – all of a sudden things like this... <Title title='{{foo.bar}}' on:teardown='doSomething()'/> ...don't work, unless we've specified that these JS components must implement the same Good point re versioning. A stable public API doesn't entirely solve that problem (it just means breaking changes have to be intentional), but it does mitigate it. I'm not sure how concerned we need to be about that though – for nested components, I think it's fair to expect that someone would be compiling the entire tree at once. (Standalone widgets in a non-Svelte app is a different matter.) Running everything through the compiler is actually beneficial in that regard, because we can make breaking changes (like renaming So for me it comes down to two questions:
Personally I think the answers are 'no' and 'no' – as discussed elsewhere I think adding |
Alright then, lets skip it for now. |
One of reacts strength is that components can participate in the vdom lifecycle without actually rendering to the real dom.
I could imagine a component made out of 100% custom code, such as:
And you can use the component something like this:
What do you think about this @Rich-Harris ? I would really love to support components that are 100% custom code with a well-defined API for that.
The text was updated successfully, but these errors were encountered: