Files
freeCodeCamp/common/app/toasts/redux/actions.js

21 lines
478 B
JavaScript
Raw Normal View History

import { createAction } from 'redux-actions';
import types from './types';
let key = 0;
export const makeToast = createAction(
types.makeToast,
({ timeout, ...rest }) => ({
...rest,
// assign current value of key to new toast
// and then increment key value
key: key++,
2016-07-07 19:25:31 -07:00
dismissAfter: timeout || 10000,
position: rest.position === 'left' ? 'left' : 'right'
})
);
export const removeToast = createAction(
types.removeToast,
({ key }) => key
);