Getting the name of a function provided to an `action` helper


#1

I’m assuming this isn’t possible, but wanted to see if anyone knew any better.

With ES6, you can get the name of a function. For instance:

function foo() { return true; }
function bar() { return true; }

const functionContainer = foo;

foo.name; // 'foo'
bar.name; // 'bar'
functionContainer.name; // 'foo'

In Ember, you can pass an action into an action helper. For instance:

export default Ember.Component.extend({
  actions: {
    bar() {
      return true;
    }
  }
});
{{foo-component foo=(action "bar")}}

Within foo-component, is there some way to do this:

export default Ember.Component.extend({
  doFoo: Ember.on('didRecieveAttrs', function() {
    console.log(this.attrs.foo.name); // 'bar'
  })
});

When I try, I just get a blank string. This makes sense, since it looks like the bar action is getting wrapped in a nameless function by Ember Metal.

Anyone know of a way to grab that name? It would make a huge difference for a project I’m working on.