Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. // Available variables:
  2. // - Machine
  3. // - interpret
  4. // - assign
  5. // - send
  6. // - sendParent
  7. // - spawn
  8. // - raise
  9. // - actions
  10. // - XState (all XState exports)
  11.  
  12. const fetchMachine = Machine({
  13. id: 'sortieOF',
  14. initial: 'of',
  15. context: {
  16. type: "GERE"
  17. },
  18. states: {
  19. of: {
  20. on: {
  21. NEXT: "centreEmplacement"
  22. }
  23. },
  24. centreEmplacement: {
  25. on: {
  26. NEXT: "boucle"
  27. }
  28. },
  29. boucle: {
  30. initial: "article",
  31. states: {
  32. article: {
  33. on: {
  34. NEXT: [
  35. { target: "lot", cond: "isLot" },
  36. { target: "serie", cond: "isSerie" },
  37. { target: "qte" }
  38. ]
  39. }
  40. },
  41. lot: {
  42. on: {
  43. NEXT: [
  44. { target: "serie", cond: "isLotSerie" },
  45. { target: "qte" }
  46. ]
  47. }
  48. },
  49. serie: {
  50. on: {
  51. NEXT: "qte"
  52. }
  53. },
  54. qte: {
  55. on: {
  56. NEXT: "article"
  57. }
  58. }
  59. },
  60. on: {
  61. EXIT: "recap"
  62. }
  63. },
  64. recap: {
  65. type: "final"
  66. }
  67. }
  68. }, {
  69. guards: {
  70. isLot: ctx => ctx.type === "LOT" || ctx.type === "LOTSERIE",
  71. isSerie: ctx => ctx.type === "SERIE",
  72. isLotSerie: ctx => ctx.type === "LOTSERIE",
  73. isGere: ctx => ctx.type === "GERE"
  74. }
  75. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement