actions.ts
1 import * as types from './types'; 2 3 export type TShowNotification = typeof showNotification; 4 export function showNotification( 5 level: types.NotificationLevel = 'info', 6 msg: string, 7 duration?: number 8 ): types.ShowNotificationAction { 9 return { 10 type: types.NotificationsActions.SHOW, 11 payload: { 12 level, 13 msg, 14 duration, 15 id: Math.random() 16 } 17 }; 18 } 19 20 export type TShowNotificationWithComponent = typeof showNotificationWithComponent; 21 export function showNotificationWithComponent( 22 level: types.NotificationLevel, 23 msg: string, 24 componentConfig: { 25 component: string; 26 [restProp: string]: any; 27 }, 28 duration?: number 29 ): types.ShowNotificationAction { 30 return { 31 type: types.NotificationsActions.SHOW, 32 payload: { 33 id: Math.random(), 34 level, 35 msg, 36 rendersComponent: true, 37 componentConfig, 38 duration 39 } 40 }; 41 } 42 43 export type TCloseNotification = typeof closeNotification; 44 export function closeNotification(notification: types.Notification): types.CloseNotificationAction { 45 return { 46 type: types.NotificationsActions.CLOSE, 47 payload: notification 48 }; 49 }