martinmodrak is updating a custom theme component and needs to display different content based on the user’s device (mobile vs. normal view). They initially attempted to use this.site.mobileView within apiInitializer but it didn’t work. Alteras pointed out the need to manually import the site service using `api.container.lookup(
Trying to update our custom theme component to the new standard after the deprecation notice and I can’t figure out how to show different stuff for mobile users in this setting.
The theme guide doesn’t mention anything about this, the only relevant post I found is api.renderInOutlet not rendering? - #3 by NateDhaliwal which uses this.site.mobileView so I assumed something like the following should work:
No. The @service decorator is only available in Ember classes like Components or Services. If the <template>...</template> was refactored as a separate component, then you can use the decorator. As the apiInitializer() is only a function, the service has to be accessed like normal JS.