constant

Constant manager. It manages all constants of a feature. Constants are very useful for the communication between actions and reducers. They may be used across features. This constant manager exports APIs to create/rename/remove constants. Usually used with the action manager as Rekit does.

Source:

Methods

(static) add(feature, name)

Source:

Add a constant definition to a feature's redux/constants.js file, it forces UPPER_SNAKE_CASE.

Example

Add a new constant

const constant = require('rekit-core').constant;

// Define a new constant named 'FETCH_TOPIC_LIST_BEGIN'.
constant.add('home', 'fetch-topic-list-begin');

// Write the changes to disk. Otherwise only in memory, see more at rekitCore/vio
rekitCore.vio.flush();

// Result => added a new line `const FETCH_TOPIC_LIST_BEGIN = 'FETCH_TOPIC_LIST_BEGIN';` to `home/redux/constants.js`.
Parameters:
Name Type Description
feature string

The feature name.

name string

The component name.

(static) remove(feature, name)

Source:

Remove a constant definition from a feature's redux/constants.js file, it forces UPPER_SNAKE_CASE.

Parameters:
Name Type Description
feature string

The feature name.

name string

The component name.

(static) rename(feature, name)

Source:

Rename a constant definition in a feature's redux/constants.js file, it forces UPPER_SNAKE_CASE.

Parameters:
Name Type Description
feature string

The feature name.

name string

The component name.