A service instance can be used by components that need to communicate to each other or share a
common state. If these two components originate from different code bases, e.g. are deployed via
plugin-ins, then
hookService
comes as a way for such a shared service to be injected. The service interface might be declared
in a shared library known at compile time.
This example showcases two component instances that share a counter service. The counter service
interface is declared in the
counder.model
module which may be declared in a common library shared between plug-ins in a real world case.
The
CounterHookModule
leverages
hookService
to inject a service instance. This can happen in a plugin or in a shell application.
Component A
Component B