Last active
September 24, 2015 20:16
-
-
Save listepo/b48ba4bca5a3361ea94e to your computer and use it in GitHub Desktop.
Mixin(Ember.js) for application controller/component
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.Mixin.create({ | |
uiSettings: null, | |
init() { | |
let uiSettings = this.get('uiSettings'); | |
if (!Ember.$.isPlainObject(uiSettings)) { | |
throw new Ember.Error('uiSettings must be object'); | |
} | |
Ember.$.each(uiSettings, (moduleName, settings) => { | |
let Module = Ember.$.fn[moduleName]; | |
if (!Ember.$.isPlainObject(Module.settings)) { | |
throw new Ember.Error('Module must have settings object'); | |
} | |
Module.settings = Ember.$.extend(true, Module.settings, settings); | |
}); | |
this._super(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use: