3 ms·
I'm actually working on one. I don't know what will come out of it, but it's an interesting endeavor. As soon as it's shareable I will share it on Github. I'm
by Trufa 7y ago
I'm actually working on one. I don't know what will come out of it, but it's an interesting endeavor. As soon as it's shareable I will share it on Github.
I'm basically trying to do a superset of typescript where you create elements so:
const root = c({
el: 'div',
children: [
`hello, ${store.user.name}`
],
attr: {
class: 'bold smart',
id: 'abc',
bla: true,
},
evts: {
click: () => {
console.log("Clicked")
}
}
});
And store store.user.name is "magically" reactive.
Was that what you meant?
- bufferoverflow 7y agoThat is awfully verbose.
- Trufa 7y agoI'll hopefully add jsx eventually that will help with the visual aspect of the verbosity.
- wolfadex 7y agoWhat's wrong with being verbose?
- bufferoverflow 7y agoYou need to write more, you need to read more, and whoever maintains your code will need to read more. More chances for typos. That means more time wasted for everyone. Why do you think we have async/await now instead of manually typing out all the promise syntaxic mess every time?
- tekknik 7y agobecause handling a promise using .then/.catch creates a new block? verbosity isn’t an issue as much as being too terse, especially with macros
- chrismorgan 7y agoWhat you’ve written there couldn’t possibly be reactive without compilation or wrapping it in a function. Is there something else wrapping it (a function), or is it being compiled into a different form? If it’s being compiled (so that the code means something other than it seems to), then I see no particular advantage to using TypeScript syntax, given it’s more verbose than need be. For reference, in Svelte that’d be something like this, which is shorter and more obvious: <div class="bold smart" id="abc" bla={true} on:click={() => { console.log("Clicked") }> hello, {store.user.name} </div>
- Trufa 7y agoYes, that's currently what I'm experimenting with. This is very early stages and completely experimental. The idea I'm experimenting is to compile typescript to another form, I completely see your point about too verbose though, but I'm also toying around with jsx. Basically what I'm trying to do is a svelte where instead of this: {#each cats as { id, name }, i} <li> <a target="_blank" href="https://www.youtube.com/watch?v={id}"> {i + 1}: {name} </a> </li> {/each} You have have the native JavaScript map functions and so on. Again, this is completely in the early stages and just playing around until something feels right. Any recommendations appreciated.
- syspec 7y agoUsing 'evts' instead of events is a good way to get people to make mistakes
- Trufa 7y agoThanks for the feedback :)
- Casperin 7y agoIs there any framework that explicitly allows me to set properties instead of just attributes? It doesn't play nice with web components when the object you passed in comes out as a string "[object Object]".
- Trufa 7y agoWhat do you mean? how would it look?