Thanks for this great article, but do you have a link to next one of the series? Sharing data between components using a service? Much appreciated, thanks.
Hi Beto, sadly I never got to it...but essentially if the service is provided in root then it is a singleton, meaning you have just one instance of it during it's lifetime.
That means any value you hold in it essentially is available to any component no matter how nested by injecting the service so then you won't find yourself having to continuously pass down the value through a whole tree of components.
I don't recommend exposing or accessing that variable in the service directly. Instead, write a method that accesses it.
Thanks for this great article, but do you have a link to next one of the series? Sharing data between components using a service? Much appreciated, thanks.
Hi Beto, sadly I never got to it...but essentially if the service is provided in root then it is a singleton, meaning you have just one instance of it during it's lifetime.
That means any value you hold in it essentially is available to any component no matter how nested by injecting the service so then you won't find yourself having to continuously pass down the value through a whole tree of components.
I don't recommend exposing or accessing that variable in the service directly. Instead, write a method that accesses it.
Here's the documentation on this: Singleton Services.