kimroen / ember-cli-document-title

Adding document title behaviour to your ember app
MIT License
216 stars 61 forks source link

Title token using an async relationship #42

Closed gzurbach closed 7 years ago

gzurbach commented 8 years ago

Hi there! First off, thanks a lot for this great add-on. I've been using it for a while and just found out a (minor) issue.

I have a models/foo.js with an async relationship to a user such as:

export default DS.Model.extend({
  title: DS.attr('string'),
  user: DS.belongsTo('user', { async: true })
});

In my routes/foo.js I have the following titleToken:

export default Ember.Route.extend({
  titleToken(model) {
    return model.get('user.firstName');
  }
});

Because useris async, user.firstNameis undefined at this point (user is still a Promise). When the promise is resolved, the title does not recompute so my title stays empty.

Would you have any recommendation about how to circumvent this issue? Thanks!

blimmer commented 8 years ago

It would be nice to add support for promises returned from the titleToken method. As a workaround, you could load the user as part of your model hook so it will be loaded when titleToken is called.

gzurbach commented 8 years ago

That did the trick, thanks!

poohitan commented 7 years ago

I've made a pull request to resolve this issue quite a long time ago, but it hasn't been reviewed and merged yet. It seems that this project is not being supported anymore :(

kimroen commented 7 years ago

I've made a pull request to resolve this issue quite a long time ago, but it hasn't been reviewed and merged yet. It seems that this project is not being supported anymore :(

Sorry about that. I don't use Ember for work at the moment, so fitting in working on addons is a bit harder than it used to be.