Forked from jeffrey-biles-q2/controllers.application.js
Last active
May 2, 2017 18:08
-
-
Save code0100fun/fa333f111a1553081d81bc2526e7fad6 to your computer and use it in GitHub Desktop.
proxying solution
This file contains 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({ | |
userService: Ember.inject.service('user'), | |
userController: Ember.inject.controller('user'), | |
actions: { | |
incrementController() { | |
this.incrementProperty('userController.counter', 1); | |
}, | |
decrementController() { | |
this.decrementProperty('userController.counter', 1); | |
}, | |
incrementService() { | |
this.incrementProperty('userService.counter', 1); | |
}, | |
decrementService() { | |
this.decrementProperty('userService.counter', 1); | |
}, | |
incrementServiceAlias() { | |
this.incrementProperty('userService.counterAlias', 1); | |
}, | |
decrementServiceAlias() { | |
this.decrementProperty('userService.counterAlias', 1); | |
}, | |
} | |
}); |
This file contains 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({ | |
counter: 1, | |
}); |
This file contains 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 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'); | |
}), | |
counterAlias: Ember.computed.alias('proxy.counter'), | |
}); |
This file contains 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