Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

redux-actiontypes-namespace

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-actiontypes-namespace

add nameSpaces to your global actionTypes in an easy way

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

redux-actionTypes-namespace

Add nameSpaces to your global actionTypes in an easy way

How to use

First install

yarn add redux-actionTypes-namespace

import createActionTypes function, example:

import createActionTypes from 'redux-actionTypes-namespace';

const actionTypes = [
  {
    nameSpace: 'nameSpace1',
    types: [
      'TYPE_NAME',
      'ANOTHER_TYPE'
    ]
  },
  {
    nameSpace: 'nameSpace2',
    types: [
      'SECOND_TYPE_NAME',
      'SECOND_ANOTHER_TYPE'
    ]
  }
];

export default createActionTypes(actionTypes);

now your actionTypes shoud be like:

  {
    TYPE_NAME: 'nameSpace1/TYPE_NAME',
    ANOTHER_TYPE: 'nameSpace1/ANOTHER_TYPE',
    SECOND_TYPE_NAME: 'nameSpace2/SECOND_TYPE_NAME',
    SECOND_ANOTHER_TYPE: 'nameSpace2/SECOND_ANOTHER_TYPE'
  }

So, now just import your actionTypes and you can use in a normal way.

 import types from 'where-your-file-was-created';

 dispatch({ type: types.TYPE_NAME })

or with object destructuring:

 import { TYPE_NAME } from 'where-your-file-was-created';

 dispatch({ type: TYPE_NAME })

made with <3

FAQs

Package last updated on 18 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts