The Feature Class is used to provide an interface to something which can be enaabled() and optionally configured() and possibly even have persistent state throughout their object lifecyle. Extended runtimes such as @skypager/node are just a normal runtime which packages certain node specific features and enable them automatically.
Kind: global class
Extends: Helper
- Feature ⇐
Helper
- instance
- static
- .createRegistry()
- .attach(runtime, options) ⇒
Runtime
This lets you create feature instances using the runtime.feature
factory method
without first registering the module with the runtime.features
registry.
Kind: instance property of Feature
Since features are cacheable, you will get the same instance of the feature back
every time you call the runtime.feature
factory method with the same arguments
Kind: instance property of Feature
Example
const one = runtime.feature('my-feature')
const two = runtime.feature('my-feature')
const three = runtime.feature('my-feature', { cacheHelper: false })
console.assert(one.uuid === two.uuid)
console.assert(three.uuid !== two.uuid)
Enable the feature.
Kind: instance method of Feature
Param | Type |
---|---|
options | object | function |
Kind: static method of Feature
Attaches this helper class to a runtime.
Kind: static method of Feature
Param | Type | Default | Description |
---|---|---|---|
runtime | Runtime |
the runtime to attach the Feature registry to | |
options | Object |
options to pass through to Helper.attach |
|
[options.lookupProp] | String |
'feature' |
the name of the factory function to create on the runtime |
[options.registryProp] | String |
'features' |
the name of the registry prop to create on the runtime |