Proposal: Ember.computed.dynamic to use CP keys determined dynamically at runtime

I have a use-case for dynamically determining a computed property key from another property on an object. I created a CP macro called Ember.computed.dynamic that takes two properties on the current object: the first one is the property that has a value that will change, the second one evaluates to the key we need from the first. All of this leads to a UI where the user can hide/show the values they want, sort them, and I can live-update them via ajax polling.

My Ember.computed.dynamic macro is mostly working. I’ve put together a silly example of this working in a jsbin.

The only problem I’m running into is that the dynamic bindings cannot be created until the first time the property is retrieved.

This seems like the strong use case @pwagenet mentioned in #1128. Would it be worth trying to integrate this into ember-metal/lib/computed.js and sending a PR?

Along those lines, is anyone willing to pair with me to fix the problem I mentioned above?

The effect of this problem was that I couldn’t use dynamic properties as dependencies in other properties. I have now solved this by reopening “init” on Ember.Object and performing the first call to the property in there. You can see these changes reflected in my updated jsbin.

Where does this fit into core Ember?