Service¶
-
class
Service¶ A Service is, as the name indicates* a provider of services for other components.
It is declared in the
services = {name: ServiceClass,}directive of Component and Module classes, to enable functionality like for example an http client, a search service, a logging facility, etc.Directives:
bindings ({}):A dictionary containing the name and default value of attributes for the class which will also automatically add bound
ObservablesThe observables will have a
_(underscore) character appended.Setting the value of the attribute will trigger the observable and therefore any actions/subscriptions associated with it. Example:
bindings = {‘myattr’: ‘myvalue’}
will create:
An attribute
myattrwhich defaults tomyvalueAn observable
myattr_
Attributes:
_parent: holds the instance of Component or Module in which the service was instantiated (use with care)_module: holds the instance of Module in which the service (somewhere along the hierarchy) is. This will be the same as_parentif the service is declared in a Module (use with care)
Attribute Searching:
Subclasses of
Servicewill access the attributes ofself._parentif the attribute is not found as an instance/class attribute.