npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

myreduxtypes

v2.0.0

Published

get dinamic types and actions for redux

Downloads

7

Readme

myreduxtypes

N|Solid

myreduxtypes is a lightweight package which allows you to autogenerate redux types

Features!

  • Generate types for CRUD operation /CREATE/REMOVE/FIND/GET/PATCH and plus SET/LOADING
  • Generate customised types for some specific needs

Usage

myreduxtypes requires Node.js v4+ to run.

Install the dependencies and devDependencies and start the server.

$ cd my-app
$ npx create-react-app .
$ npm i redux react-redux  --save
$ npm i myreduxtypes --save
$ npm start

In Redux Module

First you need to import package\

For common js

const { autoTypeGen, } = require('myreduxtypes');

For ES6 and higher

import {autoTypeGen, customTypeGen,simpleTypeGen} from 'myreduxtypes'

For autoTypeGen

export const [types, actions] = autoTypeGen('product')

And with only this line of code you are having CRUD operation ready types and actions

Types

{
  CREATE_START: 'CREATE_PRODUCT_START',
  CREATE_SUCCESS: 'CREATE_PRODUCT_SUCCESS',
  CREATE_FAILED: 'CREATE_PRODUCT_FAILED',
  LOADING: 'PRODUCT_LOADING',
  SET_CURRENT: 'PRODUCT_SET_CURRENT',
  PATCH_START: 'PATCH_PRODUCT_START',
  PATCH_SUCCESS: 'PATCH_PRODUCT_SUCCESS',
  PATCH_FAILED: 'PATCH_PRODUCT_FAILED',
  REMOVE_START: 'REMOVE_PRODUCT_START',
  REMOVE_SUCCESS: 'REMOVE_PRODUCT_SUCCESS',
  REMOVE_FAILED: 'REMOVE_PRODUCT_FAILED',
  GET_START: 'GET_PRODUCT_START',
  GET_SUCCESS: 'GET_PRODUCT_SUCCESS',
  GET_FAILED: 'GET_PRODUCT_FAILED',
  FIND_START: 'FIND_PRODUCT_START',
  FIND_SUCCESS: 'FIND_PRODUCT_SUCCESS',
  FIND_FAILED: 'FIND_PRODUCT_FAILED'
}

Actions

{
  create_start: [Function (anonymous)],
  create_success: [Function (anonymous)],
  create_failed: [Function (anonymous)],
  loading: [Function (anonymous)],
  set_current: [Function (anonymous)],
  patch_start: [Function (anonymous)],
  patch_success: [Function (anonymous)],
  patch_failed: [Function (anonymous)],
  remove_start: [Function (anonymous)],
  remove_success: [Function (anonymous)],
  remove_failed: [Function (anonymous)],
  get_start: [Function (anonymous)],
  get_success: [Function (anonymous)],
  get_failed: [Function (anonymous)],
  find_start: [Function (anonymous)],
  find_success: [Function (anonymous)],
  find_failed: [Function (anonymous)]

}

Each action function accepts two arguments optionally /data and route

actions.create_start(data,'/')

output====>
{ type: 'CREATE_PRODUCT_START', payload: data, route: '/' }

Custom types with myreduxtypes

import { autoTypeGen} from 'myreduxtypes'

export const [types,actions]=autoTypeGen("user","login","register");

You will get types and actions for each argument provided to autoTypeGen

{
  LOGIN_START: 'LOGIN_USER_START',
  LOGIN_SUCCESS: 'LOGIN_USER_SUCCESS',
  LOGIN_FAILED: 'LOGIN_USER_FAILED',
  LOADING: 'USER_LOADING',
  REGISTER_START: 'REGISTER_USER_START',
  REGISTER_SUCCESS: 'REGISTER_USER_SUCCESS',
  REGISTER_FAILED: 'REGISTER_USER_FAILED'
}

More

To have both CRUD and optional types you need to provide boolien argument a the end by default its false

import { autoTypeGen} from 'myreduxtypes'

export const [types,actions]=autoTypeGen("user","login","register",true);

Package will generate

{
  CREATE_START: 'CREATE_USER_START',
  CREATE_SUCCESS: 'CREATE_USER_SUCCESS',
  CREATE_FAILED: 'CREATE_USER_FAILED',
  LOADING: 'USER_LOADING',
  SET_CURRENT: 'USER_SET_CURRENT',
  PATCH_START: 'PATCH_USER_START',
  PATCH_SUCCESS: 'PATCH_USER_SUCCESS',
  PATCH_FAILED: 'PATCH_USER_FAILED',
  REMOVE_START: 'REMOVE_USER_START',
  REMOVE_SUCCESS: 'REMOVE_USER_SUCCESS',
  REMOVE_FAILED: 'REMOVE_USER_FAILED',
  GET_START: 'GET_USER_START',
  GET_SUCCESS: 'GET_USER_SUCCESS',
  GET_FAILED: 'GET_USER_FAILED',
  FIND_START: 'FIND_USER_START',
  FIND_SUCCESS: 'FIND_USER_SUCCESS',
  FIND_FAILED: 'FIND_USER_FAILED',
  LOGIN_START: 'LOGIN_USER_START',
  LOGIN_SUCCESS: 'LOGIN_USER_SUCCESS',
  LOGIN_FAILED: 'LOGIN_USER_FAILED',
  REGISTER_START: 'REGISTER_USER_START',
  REGISTER_SUCCESS: 'REGISTER_USER_SUCCESS',
  REGISTER_FAILED: 'REGISTER_USER_FAILED'
}

For Custom types

const {  customTypeGen } = require('myreduxtypes');
export const [types,actions]=autoTypeGen("modal","open","close",'toggle');
  • Types
{
  MODAL_OPEN: 'MODAL_OPEN',
  MODAL_CLOSE: 'MODAL_CLOSE',
  MODAL_TOGGLE: 'MODAL_TOGGLE'
}
  • Actions
{
  modal_open: [Function (anonymous)],
  modal_close: [Function (anonymous)],
  modal_toggle: [Function (anonymous)]
}.
  • You cann pass arguments optionally
actions.modal_open()
==================================
{ type: 'MODAL_OPEN', payload: undefined, route: undefined }