2016-07-06 11:47:16 -07:00
|
|
|
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,
|
2016-07-06 11:47:16 -07:00
|
|
|
position: rest.position === 'left' ? 'left' : 'right'
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
export const removeToast = createAction(
|
|
|
|
types.removeToast,
|
|
|
|
({ key }) => key
|
|
|
|
);
|