@nju33/reducer-action
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

ReducerAction

CircleCI TypeScript code style: prettier

Install

yarn add -D @nju33/reducer-action

Example

import {ReducerAction} from '@nju33/reducer-action';

const enum ActionType {
  A,
  B,
}

const action = {
  a() {
    return {
      type: ActionType.A as ActionType.A,
      payload: {
        foo: 'foo',
      },
    };
  },
  b() {
    return {
      type: ActionType.B as ActionType.B,
      payload: {
        bar: 'bar',
      },
    };
  },
};

type Action = ReducerAction<typeof action>;

const aAction: Action = action.a() as any;

switch (aAction.type) {
  case ActionType.A: {
    aAction.payload.foo;
    break;
  }
  case ActionType.B: {
    aAction.payload.bar;
    break;
  }
  default:
}

Readme

Keywords

Package Sidebar

Install

npm i @nju33/reducer-action

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

2.47 kB

Total Files

7

Last publish

Collaborators

  • nju33