Module: web-toggle-point-features

Application code for holding feature toggle state

Interfaces

ContextFeaturesStore
FeaturesStore
SingletonFeaturesStore

Members

(static) globalFeaturesStore

Implements:

(static) nodeRequestScopedFeaturesStore

Implements:

(static) reactContextFeaturesStore

Implements:

(static) ssrBackedReactContextFeaturesStore

Implements:

Methods

(static) globalFeaturesStoreFactory(params) → {module:web-toggle-point-features.globalFeaturesStore}

A factory function used to create a store for features, held globally in the application. This is a singleton, and should not be used server-side for anything user or request specific. A thin wrapper around a singleton, used as an extension point for future plugins. Consider deep freezing the value to prevent accidental mutation, if this is intended to be static. For reactive decisions, consider implementing something that allows for reactivity e.g. a valtio/vanilla proxy, and subscribe appropriately in a toggle point.
Parameters:
Name Type Description
params object parameters
Properties
Name Type Description
toggleType string The type of toggle in the store, used for debugging
Implements:
Returns:
A store for features, held globally in the application.
Type
module:web-toggle-point-features.globalFeaturesStore

(static) nodeRequestScopedFeaturesStoreFactory(params) → {module:web-toggle-point-features.nodeRequestScopedFeaturesStore}

A factory function used to create a store for features, held in request-scoped global value. Should only be used server-side, for anything user or request specific. A thin wrapper around node AsyncLocalStorage, used as an extension point for future plugins.
Parameters:
Name Type Description
params object parameters
Properties
Name Type Description
toggleType string The type of toggle in the store, which should be unique within a javascript realm.
Implements:
Returns:
A store for features, scoped for the current request.
Type
module:web-toggle-point-features.nodeRequestScopedFeaturesStore

(static) reactContextFeaturesStoreFactory(params) → {module:web-toggle-point-features.reactContextFeaturesStore}

A factory function used to create a store for features, held in a React context. A thin wrapper around a context, used as an extension point for future plugins.
Parameters:
Name Type Description
params object parameters.
Properties
Name Type Description
name string The name of type of toggle in the store, used for debugging and the display name of the react context provider.
Implements:
Returns:
A store for features, held within a React context.
Type
module:web-toggle-point-features.reactContextFeaturesStore

(static) ssrBackedReactContextFeaturesStoreFactory(params) → {module:web-toggle-point-features.ssrBackedReactContextFeaturesStore}

A factory function used to create a store for features, held in a React context, backed by server-side rendering. A wrapper around a reactContextFeaturesStore, with server-side rendering supplied by the toggle-point-ssr package.
Parameters:
Name Type Description
params object parameters
Properties
Name Type Attributes Default Description
namespace string <optional>
"toggles" The namespace for the script tag used to inject the initial state into the client-side application.
toggleType string The type of toggle in the store, used for debugging, display name of the react context provider, the script name of the json script and the prop name used to pass the value to the provider.
logWarning function A function to log warnings, used to highlight any malformed JSON in-case this is processed outside of the SSR process.
Implements:
Returns:
A store for features, held within a React context.
Type
module:web-toggle-point-features.ssrBackedReactContextFeaturesStore

Type Definitions

FeaturesStoreFactory(params) → {module:web-toggle-point-features.FeaturesStore}

Factories for feature toggle stores
Parameters:
Name Type Description
params object parameters
Properties
Name Type Description
toggleType string The type of toggle in the store
Returns:
A store for features
Type
module:web-toggle-point-features.FeaturesStore