3 ms·
That hyperx onclick example [1] is really clever if I understand it correctly from a quick overview [2]. It stores a reference to the event using the template l
by franciscop 9y ago
That hyperx onclick example [1] is really clever if I understand it correctly from a quick overview [2]. It stores a reference to the event using the template literals features (reading manually the interpolated arguments):
html`<button onclick=${() => alert("Hi")}>Click</button>`
Not sure how it is attached then; from the syntax it can only be a traditional onclick="" event, however in the examples [3] [4] they are attached as an addEventListener() events. I'd have to dig deeper to understand it.
I've done something slightly similar in the past:
dom.body.html = `<button ${evt.on.click(e => console.log(e))}>Click me</button>`;
However, for that syntax above I'm using two different tiny libraries I made while the author could combine both of them into one + virtual DOM. Great work there!
Honest question as the author seems the submitter, what are the target developers for your library? It seems (to me) that virtual dom + JSX is overkill for simple websites, while the big webapps seems to want the enterprise-backed React/Angular/Ember/Etc.
[1] https://github.com/hyperapp/hyperapp/blob/master/docs/hyperx.md#about-hyperx https://github.com/hyperapp/hyperapp/blob/master/docs/hyperx...
[2] https://github.com/hyperapp/hyperapp/blob/master/src/app.js#L5 https://github.com/hyperapp/hyperapp/blob/master/src/app.js#...
[3] https://hyperapp.glitch.me/clicks https://hyperapp.glitch.me/clicks
[4] https://hyperapp.glitch.me/slider https://hyperapp.glitch.me/slider
- jbucaran 9y ago> What are the target developers for your library? Anyone. Big app devs, small app devs. For the record, you can user hyperapp with any of the following technologies: - JSX - A string template literal based solution like hyperx or t7. - The built-in hyperscript-style `h` function (https://goo.gl/da3U3P https://goo.gl/da3U3P).
- finchisko 9y agoAny example on jsx? Is it react jsx or something else? Edit: already found example in project github. Looks promising. Currently I'm looking for solution to replace jquery for one small popup for Chrome KeePassXC extension. HyperApp seems like good match. Thanks.
- jbucaran 9y agoThanks! You can find more examples on CodePen. - https://codepen.io/hyperapp https://codepen.io/hyperapp