Last active
May 2, 2017 17:55
-
-
Save jeffrey-biles-q2/9f1fd87bc66ab33f0fcd9ddd245b138d to your computer and use it in GitHub Desktop.
proxying solution
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.Controller.extend({ | |
appName: 'Ember Twiddle', | |
user: Ember.inject.service(), | |
onControllerBool: true, | |
computedFromPolicy: Ember.computed.alias('user.policy.canFind') | |
}); |
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.Controller.extend({ | |
userThing: true, | |
computedThing: Ember.computed('userThing', function(){ | |
return this.get('userThing'); | |
}), | |
}); |
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 Em from 'ember'; | |
export default Em.Mixin.create({ | |
unknownProperty: function(key) { | |
return this.get('proxy').get(key); | |
}, | |
init() { | |
this._super(...arguments); | |
var controller = this.get('proxy'); | |
for (var method in controller) { | |
if (typeof controller[method] === 'function') { | |
if (!this[method]) { | |
this.proxyMethod(method); | |
} | |
} | |
} | |
}, | |
proxyMethod: function(method) { | |
this[method] = function() { | |
var controller = this.get('proxy'); | |
return controller[method](...arguments); | |
}; | |
}, | |
}); |
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'; | |
import ProxyMixin from '../mixins/proxy'; | |
export default Ember.Controller.extend(ProxyMixin, { | |
proxy: Ember.computed(function() { | |
return this.container.lookup('controller:user'); | |
}) | |
}); |
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
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "1.13.13", | |
"ember-template-compiler": "1.13.13", | |
"ember-testing": "1.13.13" | |
}, | |
"addons": { | |
"ember-data": "1.13.15" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment