-
-
Save danlourenco/bc22045e03cbbcd41fc8c32444fe2889 to your computer and use it in GitHub Desktop.
Implementation of the missing "Ember.computed.dynamicAlias"
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'; | |
// @see http://emberjs.jsbin.com/beboga/edit?js,output | |
export default function dynamicAlias(target, keyKey) { | |
var prefix = target ? `${target}.` : ''; | |
var dynamicAliasKey = `${prefix}${keyKey}_alias`; | |
return Ember.computed(function() { | |
var key = `${prefix}${this.get(keyKey)}`; | |
Ember.defineProperty(this, dynamicAliasKey, Ember.computed.alias(key)); | |
return this.get(key); | |
}).property(keyKey, dynamicAliasKey); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment