piotrwitek / typesafe-actions

Typesafe utilities for "action-creators" in Redux / Flux Architecture
https://codesandbox.io/s/github/piotrwitek/typesafe-actions/tree/master/codesandbox
MIT License
2.41k stars 98 forks source link

Release candidate 0 #2

Closed piotrwitek closed 6 years ago

piotrwitek commented 6 years ago

New:

const increment = createAction('INCREMENT'); const type: 'INCREMENT' = getType(increment); expect(type).toBe('INCREMENT');

// in reducer switch (action.type) { case getType(increment): return state + 1;

default: return state; }


Change:
- createAction - return action creator instance type access using getType instance method
```ts
const increment = createAction('INCREMENT');
// now to get the type of action creator with imperative API use
expect(increment.getType!()).toBe('INCREMENT');
// or "FP" style
expect(getType(increment)).toBe('INCREMENT');

Update: