Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Services & Component Collaboration

Services & Component Collaboration

Talk given June 2014 on the Ember.js Hangout On Air

Kerrick Long

June 17, 2014
Tweet

More Decks by Kerrick Long

Other Decks in Programming

Transcript

  1. Kerrick Long Things I make and do Where to find

    me online meetup.com/STLEmber Lead Front-end Developer at Second Street www.KerrickLong.com twitter.com/KerrickLong github.com/Kerrick
  2. App.GeolocationService = Ember.Service.extend({ getPosition: function() { /* Logic */ }

    }) App.NearbyTweetsRoute = Ember.Route.extend({ model: function() { return this.get('services.geolocation') .getPosition().then(function(loc) { return this.get('services.twitter') .findNearbyTweets(loc); }.bind(this)); } })
  3. “I hope this can be a starting point for the

    community to start evolving on our shared understanding of what services are.” — Tom Dale
  4. Ember.Application.initializer({ name: 'injectGeolocation', before: 'geolocation', initialize: function(container, application) { var

    n='geolocation', l='service:geolocation' application.inject('controller', n, l) application.inject('route', n, l) } });
  5. App.XAccordionComponent = Em.Component.extend({ tagName: 'x-accordion', init: function() { this._super() this.set('accordionItems',

    Em.ArrayProxy.create({ content: [] })) }, registerItem: function(accordionItem) { this.get('accordionItems').addObject(accordionItem) }, activeItem: null, toggleItem: function(accordionItem) { var isActive = accordionItem === this.get('activeItem') var newActiveItem = isActive ? null : accordionItem this.set('activeItem', newActiveItem) } })
  6. App.XAccordionComponent = Em.Component.extend({ tagName: 'x-accordion', init: function() { this._super() this.set(‘accordionItems',

    Em.ArrayProxy.create({ content: [] })) }, registerItem: function(accordionItem) { this.get(‘accordionItems').addObject(accordionItem) }, activeItem: null, toggleItem: function(accordionItem) { var isActive = accordionItem === this.get('activeItem') var newActiveItem = isActive ? null : accordionItem this.set('activeItem', newActiveItem)
  7. App.XAccordionComponent = Em.Component.extend({ tagName: 'x-accordion', init: function() { this._super() this.set('accordionItems',

    Em.ArrayProxy.create({ content: [] })) }, registerItem: function(accordionItem) { this.get('accordionItems').addObject(accordionItem) }, activeItem: null, toggleItem: function(accordionItem) { var isActive = accordionItem === this.get('activeItem') var newActiveItem = isActive ? null : accordionItem this.set('activeItem', newActiveItem) } })
  8. App.AccItemComponent = Em.Component.extend({ tagName: 'acc-item', accordion: Em.computed.alias('parentView'), init: function() {

    this._super() this.get('accordion').registerItem(this) }, isExpanded: Em.computed.equal('accordion.activeItem', '@this') })
  9. App.AccItemComponent = Em.Component.extend({ tagName: 'acc-item', accordion: Em.computed.alias('parentView'), init: function() {

    this._super() this.get('accordion').registerItem(this) }, isExpanded: Em.computed.equal('accordion.activeItem', '@this') })
  10. App.AccItemComponent = Em.Component.extend({ tagName: 'acc-item', accordion: Em.computed.alias('parentView'), init: function() {

    this._super() this.get('accordion').registerItem(this) }, isExpanded: Em.computed.equal('accordion.activeItem', '@this') })
  11. HEY, WAIT! TIE IT ALL TOGETHER. THERE IS NO COHESIVENESS

    TO THOSE TOPICS. YOU REALLY SHOULD DO SOMETHING TO MAKE YOUR TALK FEEL LIKE AN ORGANIZED WHOLE. IF YOU’RE NOT EVEN GOING TO BOTHER WITH SOME SORT OF CONCLUSION TO ROUND UP EVERYTHING YOU JUST TALKED ABOUT, THEN WHAT ARE WE ALL EVEN DOING HERE ANYWAYS?