Created
January 15, 2021 04:01
-
-
Save pavankataria/47c2b1cdd6257d4ed90f917e74463cdd to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const addToUpload = assign({ | |
uploadAmount: (context, event) => context.uploadAmount + 2 | |
}); | |
const addToDownload = assign({ | |
downloadAmount: (context, event) => context.downloadAmount + 2 | |
}); | |
const fileMachine = Machine({ | |
id: 'file', | |
type: 'parallel', | |
context: { | |
uploadAmount: 0, | |
downloadAmount: 0, | |
}, | |
states: { | |
upload: { | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
INIT_UPLOAD: { | |
target: 'pending', | |
actions: 'addToUpload' | |
} | |
} | |
}, | |
pending: { | |
on: { | |
UPLOAD_MORE: { | |
target: 'pending', | |
actions: 'addToUpload' | |
} | |
} | |
}, | |
success: {} | |
} | |
}, | |
download: { | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
INIT_DOWNLOAD: { | |
target: 'pending', | |
actions: 'addToDownload' | |
} | |
} | |
}, | |
pending: { | |
on: { | |
DOWNLOAD_MORE: { | |
target: 'pending', | |
actions: 'addToDownload' | |
} | |
} | |
}, | |
success: {} | |
} | |
} | |
} | |
},{ | |
actions: { addToUpload, addToDownload } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment