What is the lifecycle of a Service?

I love the idea of using services. I’m curious about their lifecycles, though. Do they initialize when they’re injected into an object? Or do they initialize alongside the app itself? I’m assuming the latter, since you can use them to communicate across objects. But perhaps there’s more to the story, especially since they have an isDestroying property. What would prompt them to be destroyed? Or created?

They are singleton’s (meaning there is only a single instance in your entire application), and they are only created when you get them (this.get('serviceName') ). They would only be destroyed when the whole application is destroyed.

2 Likes