0.0.2 • Published 6 years ago

@nju33/reducer-action v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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:
}
0.0.2

6 years ago

0.0.1

6 years ago