Skip to content

Instantly share code, notes, and snippets.

@trabus
trabus / controllers.application.js
Created May 9, 2016 18:31
multiple dynamic properties
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@trabus
trabus / application.controller.js
Created April 22, 2016 20:18
component blur demo
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@trabus
trabus / components.foo-bar.js
Last active April 8, 2016 19:35
Funky Computed Property
import Ember from 'ember';
const {Component, computed} = Ember;
export default Component.extend({
mything: null,
// thing value is also passed into the component
// thing watches no keys, and is not consumed
thing: computed({
// the getter is ignored entirely
set(k, v) {
// do any amount of work here
@trabus
trabus / account.service.js
Last active January 30, 2016 10:34
query-param-service
import Ember from 'ember';
const {computed} = Ember;
export default Ember.Service.extend({
_account: null,
account: computed('_account', {
get(key) {
return this.get('_account');
},
set(key, val) {

In 1.13.0-beta.1 and above, the childViews array is not maintained (HTMLBars maintains a tree structure instead of a flat array listing).

I spiked getting things working for both pre-1.13 and post in this JSBin, snippet below:

  didRender: function() { 
    function filterAttrMorphs(node) {
      return node.constructor.name !== 'AttrMorph';
    }
    var childViews = this._renderNode.childNodes.filter(filterAttrMorphs)[0].childNodes
 .map(function(node) {
@trabus
trabus / application.controller.js
Last active October 19, 2015 22:58
demo for brandon
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
initData: Ember.on('init',function(){
// this would normally happen with the route model hook
// when the data response comes back, this happens automatically behind the scenes
this.store.pushPayload({yearbooks:[
{id: 1, name: 'yearbook 1'},
{id: 2, name: 'yearbook 2'},
@trabus
trabus / conflicting-addons.md
Last active August 24, 2018 15:30
Handling addons with conflicting module names

Say that you have some-addon and other-addon, and both have a foo service, and both export app/services/foo.js.

What you would observe is that other-addon would win over some-addon providing the foo service in your consuming app, because modules are resolved alphabetically.

To get around this, you can essentially proxy the services in your app folder, like so:

// app/services/foo-a.js
export { default } from 'some-addon/services/foo';
@trabus
trabus / install_multiple_blueprints.js
Created September 30, 2015 22:05
Installing multiple blueprints from another blueprint
var RSVP = require('rsvp');
var assign = require('lodash/object/assign');
module.exports = {
description: '',
// creates an array of blueprints to install, for instance scaffolding
install: function(options){
var blueprints = [
{ blueprint: this.lookupBlueprint('account'),
options: options
},
@trabus
trabus / proxy_install_blueprint.js
Last active October 2, 2015 06:27
Proxy installing a blueprint from another blueprint
module.exports = {
description: '',
// overwriting install, acting as a proxy to the component-test blueprint
install: function(options){
this.project = options.project;
this.ui = options.ui;
var testBlueprint = this.lookupBlueprint('component-test');
return testBlueprint.install(options);
}
};