Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use helper and avoid component? #2

Open
rwjblue opened this issue Apr 20, 2016 · 2 comments
Open

Use helper and avoid component? #2

rwjblue opened this issue Apr 20, 2016 · 2 comments

Comments

@rwjblue
Copy link

rwjblue commented Apr 20, 2016

If we leverage normal Handlebars/HTMLBars we can do roughly the same as {{#with-service today, and avoid the cost of creating the component for each usage/invocation.

For example, with the following helper:

// app/helpers/service.js
import getOwner from 'ember-getowner-polyfill';

export default Ember.Helper.extend({
  compute([serviceName]) {
    let owner = getOwner(this);
    return owner.lookup(`service:${serviceName}`);
  }
})

You could do this in the template:

{{#with (service 'fooBarBaz') as |foo|}}
  {{! use foo here}}
{{/with}}

You could also do:

{{some-other-component derp=(service 'something')}}

This is really really close to what your API is here already, and it provides more capabilities...

@rwjblue rwjblue changed the title Avoid component? Use helper and avoid component? Apr 20, 2016
@rtablada
Copy link
Owner

I've thought about this and I think I even have it locally written up.

For backwards compat, I'd probably ship both the component and the helper, and start guiding people towards the helper.

I'm in class for the day, could you work up a PR?

@rwjblue
Copy link
Author

rwjblue commented Apr 20, 2016

Sure, I can take a crack at it this afternoon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants