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

Support headTags Promises #28

Open
ianpetzer opened this issue Nov 21, 2015 · 4 comments
Open

Support headTags Promises #28

ianpetzer opened this issue Nov 21, 2015 · 4 comments

Comments

@ianpetzer
Copy link

Is there a way to use async relationships in the headTags function?

Currently if I refer to an async relationship, then i get undefined show up in the meta tag, and I can't return a promise from headTags function.

@ronco
Copy link
Owner

ronco commented Nov 21, 2015

Hey @ianpetzer,

Good question. I like the idea of understanding a promise in headTags. It gets a little complicated in the implementation, but I'll be thinking about how it might be done. As always pull requests are welcome if you want to take a crack at it.

I think there are a couple of approaches you could use to get this working with the addon in it's current state:

  1. If you're ok with your route transition blocking until all of your async relationships resolve you could chain the promises in your model hook, or use the afterModel hook to fetch all the async relationships. This will ensure all your data is loaded by the time headTags is called.
  2. If you don't want to block your transition take a look at Resetting Tags Outside of Transition. This will let you re-populate the headTags at an arbitrary time.

Let me know if either of those work for you. I'm happy to elaborate more if you'd like.

-Ron

@ianpetzer
Copy link
Author

Ron,

Thanks so much for getting back to me. I actually implemented the first
suggested solution before contacting creating this issue.

I think the second option is a great idea, so I don't need to block the
transition.

Thanks for the great ideas.

On Sat, Nov 21, 2015 at 5:17 PM, ronco [email protected] wrote:

Hey @ianpetzer https://github.com/ianpetzer,

Good question. I like the idea of understanding a promise in headTags. It
gets a little complicated in the implementation, but I'll be thinking about
how it might be done. As always pull requests are welcome if you want to
take a crack at it.

I think there are a couple of approaches you could use to get this working
with the addon in it's current state:

If you're ok with your route transition blocking until all of your
async relationships resolve you could chain the promises in your model
hook, or use the afterModel hook to fetch all the async relationships.
This will ensure all your data is loaded by the time headTags is called.
2.

If you don't want to block your transition take a look at Resetting
Tags Outside of Transition
https://github.com/ronco/ember-cli-meta-tags#resetting-tags-outside-of-transition.
This will let you re-populate the headTags at an arbitrary time.

Let me know if either of those work for you. I'm happy to elaborate more
if you'd like.

-Ron


Reply to this email directly or view it on GitHub
#28 (comment)
.

@ronco
Copy link
Owner

ronco commented Nov 23, 2015

Great @ianpetzer! I'm glad that helped out. I'm going to keep this issue open as a possible enhancement. I like the idea of supporting promises out of the box (although the complexities might keep me from building a solution anytime soon).

@ronco ronco changed the title Using async relationships Support headTags Promises Nov 23, 2015
@Duder-onomy
Copy link

This would be incredibly helpful in fastboot

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

No branches or pull requests

3 participants