phoenex-front-ci
v2.4.0
Published
Various stuff for continuous integration in phoenex exchange
Downloads
3
Readme
CI
Various stuff for continuous integration in phoenex exchange.
Working with typesafe-actions
We're using typesafe-actions.
One should export "action type" string constant; for example, in
actions/notification.ts
:export const ADD_NOTIFICATION = '@notification/ADD_NOTIFICATION'; export const REMOVE_NOTIFICATION = '@notification/REMOVE_NOTIFICATION';
we're not using "const contexts for literal expressions" for that:
export default ({ ADD_NOTIFICATION: '@notification/ADD_NOTIFICATION', REMOVE_NOTIFICATION: '@notification/REMOVE_NOTIFICATION', } as const);
one should use
action
function fromtypesafe-actions
to make action creators; for example, inactions/notification.ts
:import { action } from 'typesafe-actions'; // ... export const addNotification = ( title: string, note: string, ) => action(ADD_NOTIFICATION, { header: title, text: note, }); export const removeNotification = (id: number) => action(REMOVE_NOTIFICATION, { id });
one shouldn't use
createStandardAction
function,one shouldn't use action helpers,
one should make reducers using
createReducer
API with type-free syntax:import { createReducer } from 'typesafe-actions'; // ... export default createReducer(INITIAL_STATE) .handleAction(ADD_NOTIFICATION, (state, action) => { ...state, { header: action.header, text: action.text, }, }) .handleAction(REMOVE_NOTIFICATION, (state, action) => { removed: true });