Guest User

Untitled

a guest
Dec 12th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. [This was posted by skilesare on HN.]() I am posting it here for better formatting:
  2.  
  3. ---
  4.  
  5. I've now shipped an Ember.js application and a knockout.js application. I enjoyed ember quite a bit but feel that knockout gives me all the magic with half the complexity.
  6.  
  7. It is true as the author mentions that it doesn't aim to fix the UI/statefullness issue, but I slapped on Backbone Routing on to my knockout code and it made capturing 'state' and urls a breeze.
  8.  
  9. The last time I used ember was 0.9.6 and I don't think this routing stuff was even in it so I was excited to see talk about it. Unfortunately it looks to be even more complicated then I expected it to. :(
  10.  
  11. Knockout may be creating some massive memory footprint in the background that will bite me down the line, but I'm writing significantly less code than I was with Ember. For example, In ember you have to create view objects and if you want your view objects to sync data with your controller you have to explicitly define them:
  12.  
  13. ``` javascript
  14. App.userController = Ember.Object.create({
  15. content: Ember.Object.create({
  16. firstName: "Albert",
  17. lastName: "Hofmann",
  18. posts: 25,
  19. hobbies: "Riding bicycles"
  20. })
  21. });
  22.  
  23. App.UserView = Ember.View.extend({
  24. templateName: 'user',
  25. firstNameBinding: 'App.userController.content.firstName',
  26. lastNameBinding: 'App.userController.content.lastName'
  27. });
  28. ```
  29.  
  30. Now I get to do my handlebars template
  31.  
  32. ```
  33. <script>
  34. <div>{{firstName}}</div>
  35. </script>
  36. ```
  37.  
  38. In knockout just have to do:
  39.  
  40. ``` javascript
  41. App.UserController = {
  42. content: ko.observable(new content());
  43. }
  44.  
  45. ko.applyBindings(App.UserController);
  46. ```
  47.  
  48. And now I get to do a knockout template inline with my html:
  49.  
  50. ``` html
  51. <div data-bind="text: content.firstName"></div>
  52. ```
  53.  
  54. It just seems like there are fewer steps with knockout and I'm getting more done. The html is a lot uglier, but it also clearer what is going on when I read it.
  55.  
  56. The ember guys have come a long way on their doc and they should be commended on it. I like the patterns they are talking about I'm just not sold that it has to be done the way they are doing it. Thanks to the author for putting together such an in depth post to me in the right direction in getting back into Ember.
Add Comment
Please, Sign In to add comment