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):
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.
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.
Any 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.
The thing that got me sold on the idea is how simple actions are. You can have them work like thunk by calling an action as a callback in another action or just return a promise. No middlewares to install, all by design of a 1kb lib.
[edit] when using, be careful with the recent API changes - it's not much, just some names, but took me a while to notice I'm reading docs to a newer version than what I've installed.
I am the author of HyperApp and also a big fan of Mithril. I'll try to compare both as fairly as I can. This is not a full or even adequate comparison, I'm just adding to the thread.
Mithril has something called auto-redrawing, that IIRC re-renders the application after DOM events by default. This can be seen as inefficient, but Mithril throttles rerenders, which ameliorate any issues caused by it.
Mithril has no state management solution out of the box.
This may be desirable if you want to experiment with different state management architectures until you find one that you like.
HyperApp has its own built-in state management solution which is inspired and draws a lot from the Elm Architecture. In this way, it's a lot like React and Redux, but since everything is built-in, there's essentially 0 boilerplate.
The drawback is that there's no other state management available for HyperApp.
Mithril has stateful components, which is a simple and useful way to reuse code across your app and easily port to other apps.
HyperApp has custom tags, which are pure functions and stateless. They only accept props and know how to render themselves. If you are coming from React, Backbone, Angular (basically everywhere else), scaling applications will seem difficult at first, but it's not, it's just different.
We are currently working on a component abstraction which is based on the idea of a fragmented state. We'll release 1.0.0 when that's done.
Mithril is bundled with m.request, which simplifies making HTTP requests.
HyperApp has no built-in facilities to help you make HTTP requests. I am not interested in a custom xhttp solution when there is a `fetch` standard.
I just used this on a Rails project where I didn't have time to integrate a complete React build pipeline. I needed it for a few small components with complex state requirements. It's been a joy to use.
My one complaint is that firing actions within actions feels imperative and could become hard to reason about. Perhaps observables could help here.
Thx. Hadn't looked at timelines, and assumed it was the other way. Great job w/ hyperapp. Congrats!
FWIW I like Elm, and hyperapp seems a delightful port of the TEA idea ... plus for being a js library, with immediate access to JS and DOM. I'll look for examples using 3rd party visual widgets, and animation libraries.
That said IMO TEA is only a convenience. What I find supremely empowering about Elm is its type inference/system. If we got that in JS-land I likely wouldn't look at another language for some time to come :)
Yes, of course, re using TypeScript or Flow. However ... I'm not a fan of TypeScript -- if I'm going to use a different "language" (albeit one that's a transpile-able thin veneer over JS) I may as well switch to a language w/ an even better type system.
Flow, from the little I know, is closer to what I want -- still JS, but an annotation or "compilation switch" makes everything typecheck.
Ha, funny -- clicking that link leads to a page w/ this message: "This page is unavailable when linked to from news.ycombinator.com. Please find a less toxic place to spend your time." :-)
I'm also really into Clojure/ClojureScript these days. I'm going to look into getting a data-oriented version of either hyperapp or picodom implemented in ClojureScript.
I'm not an author, but based on my reading of it (and I read the whole thing) it really just depends on polyfills you use with your webpack build. I'd risk saying IE10+
- Code examples: https://glitch.com/edit/#!/hyperapp
- Browser demos: https://hyperapp.glitch.me/
- README: https://github.com/hyperapp/hyperapp/blob/master/README.md
This is a good example of what an open source project should do. Straight forward. And also, refreshing to see a lite javascript framework.
One suggestion to authors: Include a link to the demonstration's code on pages like https://hyperapp.glitch.me/slider.