Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. const releasesTrackerMachine = Machine({
  2. key: 'releasesTracker',
  3. initial: 'setup',
  4. context: {
  5. releases: null,
  6. error: null
  7. },
  8. states: {
  9. setup: {
  10. type: 'parallel',
  11. states: {
  12. packageJsonUpload: {
  13. initial: 'notUploaded',
  14. states: {
  15. notUploaded: {
  16. on: {
  17. UPLOAD_PACKAGE_JSON: 'uploaded'
  18. }
  19. },
  20. uploaded: {
  21. type: 'final'
  22. }
  23. }
  24. },
  25. yarnLockUpload: {
  26. initial: 'notUploaded',
  27. states: {
  28. notUploaded: {
  29. on: {
  30. UPLOAD_YARN_LOCK: 'uploaded'
  31. }
  32. },
  33. uploaded: {
  34. type: 'final'
  35. }
  36. }
  37. }
  38. },
  39. onDone: 'releases'
  40. },
  41. releases: {
  42. initial: 'start',
  43. states: {
  44. start: {
  45. on: {
  46. FETCH_RELEASES: 'fetching'
  47. }
  48. },
  49. fetching: {
  50. invoke: {
  51. id: 'fetchReleases',
  52. src: (context, event) =>
  53. new Promise((resolve) =>
  54. resolve({})
  55. ),
  56. onDone: {
  57. target: 'fetched',
  58. actions: assign({
  59. releases: (context, event) =>
  60. event.data
  61. })
  62. },
  63. onError: {
  64. target: 'error',
  65. actions: assign({
  66. error: (context, event) =>
  67. event.data
  68. })
  69. }
  70. },
  71. on: {
  72. SUCCESS_FETCHING_RELEASES: 'fetched',
  73. ERROR_FETCHING_RELEASES: 'error'
  74. }
  75. },
  76. fetched: {},
  77. error: {}
  78. }
  79. }
  80. }
  81. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement