4 ms·
The likely reason it never caught on, is that the library has similar pitfalls to Backbone. The entire application and component lifecycle has to be coded expli
by ricardobeat 4y ago
The likely reason it never caught on, is that the library has similar pitfalls to Backbone. The entire application and component lifecycle has to be coded explicitly:
- manually attaching DOM elements to view controllers
- manually attaching child views
- models which have to be wired individually via .listenTo
- models can be out of sync
- possibility of infinite loops if the events accidentally recurse
A better tiny alternative would be hyperapp[1] or even Preact, that has a similar bundle size.
[1] https://github.com/jorgebucaran/hyperapp https://github.com/jorgebucaran/hyperapp
- bluefirebrand 4y agoThis was a lot of the problems I had when I had to work with KnockoutJS as well. So much boilerplate, I could spend a whole day writing code and barely have the same stuff written that it would take me two hours to do with React. I love stuff that makes me more productive and minimizes my boilerplate writing.
- ricardobeat 4y agoModern React code with hooks, contexts and all went almost full circle though, it's now not too far off from the amount of code you'd write with Backbone, maybe more.
- woah 4y agoYou don't have to use any of that stuff. You can still have React act as a glorified template library, drill all your data down through props, etc.
- bobthepanda 4y agoHooks, by themselves, can be ok, since you avoid componentDidMount, componentDidUnmount, etc. I’ve started enjoying functional components more once I realized I could destructure props in the function parameters rather than in the very first line of the method.
- b4je7d7wb 4y agoI hate the boilerplate in react. Import, types for props, exports and all the hooks. Many codebases I've seen have even conventions which increase it. Small things but it adds up and I unconciously avoid creating new components when possible. Many people use some shortcuts to autogenerate all of this stuff, but I don't like tools like this. Svelte is the gold standard of no boilerplate. An empty file is a valid component.
- akrymski 4y agoI don't believe any of those apply to this library. But indeed those were the issues with Backbone at the time. Check out an example app: https://github.com/akrymski/espresso.js/tree/master/examples/todomvc https://github.com/akrymski/espresso.js/tree/master/examples...
- ricardobeat 4y agoThe infinite loop for example, is easy to get with a circular chain: 'change' -> .listenTo subscriber -> triggers another change. Probably won't happen in a single file, but because updates can come from anywhere, as an app grows you are exponentially more likely to accidentally get one. The example demonstrates a couple of the downsides, like directly wiring listenTo -> render, but it has no child views or interaction between different models / collections. With a bit more complexity I'm sure it would hit all of those points. Did you ever end up building a production app with the library?
- akrymski 4y agoYes I've written several apps with it. It does have child views (to do item). You can't get a circular chain any more than with react. ListenTo is written manually only for special cases there, otherwise a controller is simply bound to a model and it's all handled for you.