lundi 11 janvier 2016

How to make promise-aware component without injecting a service?

I've just started learning Ember, and trying to create a table component. I want the table component to render loading/spinner while data is still fetching (promise is not yet fulfilled).

I found an example from a blog post - Rendering a Promise Before it Resolves - which works great. However, in my case I don't think table component would load data on its own. I think it would still more flexible to let route handles that.

Consequently, I look further and found another blog post - Promise-aware controllers and components with Ember.js. It does quite exactly on how would I prefer. However, I'm wondering if:

  1. Is mixing PromiseProxyMixin into Component, a hack, or is this the way it's designed to be used?
  2. Is there anyway to change sending data through promise property. I think it is quite strange to do:

    {{ember-table promise=model.data}}

I tried using computed field to alias the name, promise to something else, but it doesn't seem to work.




Aucun commentaire:

Enregistrer un commentaire