Closed dy closed 4 years ago
export live bindings
nope, this ain't gonna work because the module system is CommonJS, not ESM, however, when setup
is encountered the module might as well be the setup itself so it's a good hint, but the example would be:
<x-clock></x-clock>
<template is="uce-template">
<x-clock>{{time}}</x-clock>
<script type="module" setup>
let id = 0;
export default {
get time() {
return (new Date).toISOString();
}
};
this.connected = e => id = setInterval(this.render, 1000 / 30);
this.disconnected = e => clearInterval(id);
</script>
</template>
It's in, v0.2 has this behavior already 👋
Btw ... that proposal is something I haven't read at all ... like ... I've read nothing about Vue and I've never used it, so if there are other obvious things I'm missing in here, and these won't bloat the library, I'd be happy to consider other features, thanks!
P.S. <script setup="props">
also works now, so that exporting props = {a: 1, b: 2}
would make these reactive through the element
Looks awesome, lightning fast response. The context is a great DX I
believe. The concern I have though is missing vue-like reactivity - to
update clock this.render
is called (30 times more often than needed),
instead of just setting this.time = new Date
. Initially I imagined the
scheme this.props.time
- inspired by your el.props idea (https://ghub.io/element-props) some months
ago - seems intuitive and also react-like, wdyt?
On Thu, Oct 1, 2020 at 5:36 AM Andrea Giammarchi notifications@github.com wrote:
P.S. Githubissues.
Githubissues is a development platform for aggregating issues.
What was the reason for not making script a direct setup, as in the proposal? If that could also enable
scoped
-like context for the script, uce-template would be invaluable, because refs could be solved with export live bindings: