What is the lifecycle of a Service?


#1

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?


#2

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.