Skip to content

Latest commit

 

History

History
72 lines (55 loc) · 2.71 KB

feature.md

File metadata and controls

72 lines (55 loc) · 2.71 KB

Feature ⇐ Helper

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.allowAnonymousProviders

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

feature.isCacheable

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)

feature.enable(options)

Enable the feature.

Kind: instance method of Feature

Param Type
options object | function

Feature.createRegistry()

Kind: static method of Feature

Feature.attach(runtime, options) ⇒ Runtime

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