Last active
August 2, 2016 20:20
-
-
Save pwfisher/283716ad9898c7fc8101 to your computer and use it in GitHub Desktop.
Implementation of the missing "Ember.computed.dynamicAlias"
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'; | |
// @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); | |
} |
webark
commented
Feb 18, 2016
didn't need the target in the alias property
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment