Get glimmer component access to stuff from the parent

{{log "rating this parent" this.parentView._parentView.topic}}

generates an ugly error.

<RatingOne @scaleValue={{this.scaleValue}} @passedRouter={{this.router}} @topic={{this.parentView}} />

seems not to generate an error.

I really need above-topic-list-item, but thanks to your fine example, I was able to find that it should have the topic in outletArgs,

https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/components/topic-list/topic-list-item.gjs#L284

Ha! I’m going to do it!

So outletArgs means that it’s now in the this of the thing? (That’s what it looks like–I thought I would need to look in args somehow. . .)

So in my connector hbs, I can access this.topic and then I can call my component like this:

<RatingOne @name="one" @topic={{this.topic}}/>

And then in the hbs for the RatingOne component (one day to be renamed just rating since I’ve figured out how to pass stuff to it) I can

  This is topic {{this.topic.id}} {{this.topic.title}}
  This is category id: {{this.topic.category_id}})

and get the topic stuff!

And now I see the topic, now I can go add my args to the topic serializer, right? (It might be better to pass it just to to the category . . . or maybe I’ll just pass a “doTheThing” value in the serializer and get the actual stuff from SiteSettings, as I think they want this at the site and not category level).

Unless I’ve somehow stumbled on something else deprecated, it seems like you’ve done it. Thanks a zillion. :beer: :beers: :clinking_glasses: :moneybag:

3 Likes