You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import {
  2. HIDE_NOTIFICATION,
  3. SHOW_NOTIFICATION
  4. } from './actionTypes';
  5. /**
  6. * Removes the notification with the passed in id.
  7. *
  8. * @param {string} uid - The unique identifier for the notification to be
  9. * removed.
  10. * @returns {{
  11. * type: HIDE_NOTIFICATION,
  12. * uid: string
  13. * }}
  14. */
  15. export function hideNotification(uid) {
  16. return {
  17. type: HIDE_NOTIFICATION,
  18. uid
  19. };
  20. }
  21. /**
  22. * Queues a notification for display.
  23. *
  24. * @param {ReactComponent} component - The notification component to be
  25. * displayed.
  26. * @param {Object} props - The props needed to show the notification component.
  27. * @param {number} timeout - How long the notification should display before
  28. * automatically being hidden.
  29. * @returns {{
  30. * type: SHOW_NOTIFICATION,
  31. * component: ReactComponent,
  32. * props: Object,
  33. * timeout: number,
  34. * uid: number
  35. * }}
  36. */
  37. export function showNotification(component, props = {}, timeout) {
  38. return {
  39. type: SHOW_NOTIFICATION,
  40. component,
  41. props,
  42. timeout,
  43. uid: window.Date.now()
  44. };
  45. }