Last active
August 29, 2015 14:18
-
-
Save runspired/1539a7ef3caac25b2b3c to your computer and use it in GitHub Desktop.
Explicit Component Nesting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from "ember"; | |
export default Ember.Component.extend({ | |
active: false, | |
slideshow: null, | |
init: function() { | |
this._super(); | |
var slideshow = this.get('slideshow'); | |
Ember.assert("Slide has a Slideshow", slideshow); | |
slideshow.addSlide(this); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from "ember"; | |
export default Ember.Component.extend({ | |
slides: Ember.A(), | |
addSlide: function (slide) { | |
this.get('slides').addObject(slide); | |
}, | |
actions : { | |
next: function() { | |
// advance slide | |
}, | |
prev: function() { | |
// prev slide | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This method is a little more verbose, but it makes the action flow extremely clear to anyone diving into the code, and makes what constitutes a slide or a next/prev button very flexible without needing to write any
code to support different desired configurations.