Example Application of Future Ember Features
By Alex LaFroscia -- @alexlafroscia
- Routable Controllers decorate models
- Need a template or view
- No more controllers
- Route to a Component, which is already decoration + DOM
- Consolidate all long-running state
- Files are organized by type, and then name
- File are organized by name, and then type
- Easier project organization
- ember-component-css
- Actions are passed into a component as a string
- Actions are invoked in a component using
sendAction
// Component
export default Component.extend({
onClickAction: '',
click() {
const action = this.get('onClickAction');
this.sendAction(action);
}
});
- Actions are passed into a component using the
action
helper - Actions are invoked as proper functions
// Component
export default Component.extend({
click() {
this.attrs.onClickAction();
}
});
- Actions can have real return values
- Easier to pass actions down through component hierarchy
- Components use Handlebars syntax
- Arguments passed in are mutable
- Components use HTML syntax
- Arguments passed in are immutable by default
// Inline Form
<some-component foo={{bar}} />
// Block Form
<some-component foo={{bar}}>
</some-component>
- Easier to implement "Data Down, Actions Up"
To view slides, view this file with reveal-md