Sometimes in the Web Inspector console I want to quickly lookup instances or controllers etc from the console. I can’t find an easy way to do it. This is the only way I found so far: (…)
Frontend._applicationInstances.entries().next().value[0].lookup("service:session")
Where: Frontend
is the name of my app which is exported globally with ember-export-application-global
and in this example I’m looking up the service called session
.
There’s has to be a better way??
I’d probably remove ember-application-export-global and make your own instance initializer that sets self.Frontend = instance;
.
Once you do that, looking up services ends up being:
Frontend.lookup(‘service:some-name’)
Interesting and simple fix. Curious though, what is the use-case for ember-application-export-global
? I don’t fully grok what the Application
class does compared to ApplicationInstance
…
There’s a nice little section in the Ember Guides about that if you haven’t seen it yet.
ember-application-export-global was created before the concept of ApplicationInstance
s (and before the advent of a public API for accessing instantiated singletons).
Likely we could update it to the solution I linked (tied with a major version bump)…
2 Likes