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

Title token using an async relationship #42

Closed
gzurbach opened this issue May 9, 2016 · 4 comments · Fixed by #55
Closed

Title token using an async relationship #42

gzurbach opened this issue May 9, 2016 · 4 comments · Fixed by #55

Comments

@gzurbach
Copy link

gzurbach commented May 9, 2016

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
Copy link
Contributor

blimmer commented May 9, 2016

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
Copy link
Author

That did the trick, thanks!

@poohitan
Copy link
Contributor

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
Copy link
Owner

kimroen commented Mar 26, 2017

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.

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

Successfully merging a pull request may close this issue.

4 participants