How to Call A from B in Ember

867 views

Published on

A quick cheat sheet for Ember communication between layers

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
867
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

How to Call A from B in Ember

  1. 1. How to Call A From B in Ember Some ideas to try before you go crazy Ben Donaldson, Crowdly
  2. 2. Ember has many layers Like an onion Or a sandwich Or a skyscraper Or your LiveJournal
  3. 3. Ember has many changes
  4. 4. How do I talk between layers? Do those ways still work? Is it the “Ember Way”?
  5. 5. How do I talk between layers? I’ll list a bunch of ways that I found Do those ways still work? Yes, at least for the last few weeks Is it the “Ember Way”? Until it stops working
  6. 6. The List
  7. 7. The List free to use!* *You agree, to the fullest extent permitted by law, to indemnify and hold harmless Ben Donaldson against all damages, liabilities or costs, including reasonable attorneys' fees and defense costs, to the extent caused by your negligent performance of professional services under this Agreement and that of anyone for whom you are legally liable. You agree, to the fullest extent permitted by law, to indemnify and hold harmless Ben Donaldson against all damages, liabilities or costs, including reasonable attorneys' fees and defense costs, to the extent caused by your negligent acts in connection with the Project and the acts of anyone for whom you are legally liable. Neither you or I shall be obligated to indemnify the other party in any manner whatsoever for the other party's negligence. Modifications to this Agreement. Ben Donaldson reserves the right to change or modify any of the terms and conditions contained in this Agreement at any time. You acknowledge and agree that it is your responsibility to review the Presentation and these Terms of Service from time to time. Your continued use of the Presentation after such modifications to this Agreement will constitute acknowledgment of the modified Terms of Service and agreement to abide and be bound by the modified Terms of Service. Unlike kangaroos and eucalyptus-eating possums, koalas are hindgut fermenters, and their digestive retention can last for up to 100 hours in the wild, or up to 200 hours in captivity. This is made possible by the extraordinary length of their caecum—200 cm (80 in) long and 10 cm (4 in) in diameter—the largest proportionally of any animal. Koalas can select which food particles to retain for longer fermentation and which to pass through. Large particles typically pass through more quickly, as they would take more time to digest. While the hindgut is proportionally larger in the koala than in other herbivores, only 10% of the animal's energy is obtained from fermentation. Since the koala gains a low amount of energy from its diet, its metabolic rate is half that of a typical mammal, although this can vary between seasons and sexes. The koala conserves water by passing relatively dry faecal pellets high in undigested fibre, and by storing water in the caecum.
  8. 8. The List We’ll have two models, called Apple and Orange Each has their own route, controller, view, and template This is just for the simplest case
  9. 9. When I’m AppleRoute… Apple (the model) this.modelFor(‘apple’) OrangeRoute this.get(‘router’).getHandler(‘orange’) AppleController this.controllerFor(‘apple’) AppleView - no idea Apple Template - no idea
  10. 10. When I’m AppleController… Apple (the model) this.get(‘content’) (if it’s an Ember.ObjectController) AppleRoute this.get(‘target’) (if you’re currently on that route) OrangeController needs: [‘orange’] (in the root of AppleController) this.get(‘controllers.orange’) AppleView - no idea Apple Template - no idea
  11. 11. When I’m AppleView… Apple (the model) this.get(‘context’) (if AppleController is an Ember.ObjectController) this.get(‘controller.content’) (if AppleController is an Ember.ObjectController) AppleRoute this.get(‘controller.target’) (if you’re currently on that route) AppleController this.get(‘controller’) OrangeView - no idea Apple Template this.get(‘template’) (for the handlebars function, but you wouldn’t touch that much) this.get(‘element’) (for the DOM element)
  12. 12. When I’m the Apple Template… Apple (the model) this.get(‘view.context’) (if AppleController is an Ember.ObjectController) this.get(‘controller.content’) (if AppleController is an Ember.ObjectController) AppleRoute this.get(‘controller.target’) (if you’re currently on that route) AppleController this.get(‘controller’) AppleView this.get(‘view’) Orange Template - no idea
  13. 13. In case of emergency... Warning: these are not “elegant” or “the Ember Way” but could “let you meet a deadline” Make an init function and make manual connections AppleView = Em.View.extend({ init: function() { this.get(‘controller’).set(‘yourAppleView’, this); } } Ask the almighty ‘container’, available pretty much everywhere in your app. this.get(‘container’).lookup(‘view:apple’)
  14. 14. THANK YOU THESE SLIDES WILL BE ONLINE SOMEWHERE
  15. 15. THANK YOU THESE SLIDES WILL BE ONLINE SOMEWHERE obligatory tech talk meme photo -->

×