Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Custom bindings which generate DOM get you some of the way, but not quite the whole way. One of the disadvantages with custom bindings is that they are rather tightly bound to how the view model looks. If your binding expects something which isn't directly in your view model (at the right level) and perhaps requires a little transformation of your view model, you sometimes end up adding "synthetic" computed observables just to transform from your real view model to the view model that the custom binding expects. This is not really encapsulated very well. (I hope that makes sense, it's kind of hard for me to explain.)

In React it's just simple JS which you write exactly where you need it, namely where you instantiate your component -- it doesn't even have to escape the scope (vs. KO where it "pollutes" the view model in the "owning" component so to speak).

EDIT: A little addendum: It's been a while since I've used KO in any serious way, but another issue is that of embedding arbitrary components inside another. One thing is generating DOM from whole cloth, but if I have a component which just takes other components as input then the KO model breaks down.



I think I'm in the opposite situation. I've used Knockout recently, but haven't used React (I've only read their documentation). I can't think of an example of what you're talking about when you say that custom bindings are bound to how the view model looks, and that sometimes "synthetic" computed observances are needed.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: