I'm writing a Software that has the following flow:
Promise.resolve(updateMongoStatus)
.then(unzipFilesFromS3)
.then(phase4) //example
.then(phase5) //example
.then(processSomething)
.catch(saveErrorToMongo)
And I would like to know if it's ok to pass data around from the first function, to the last one, for example:
function updateMongoStatus() {
// do something here that updates Mongo and get status of some document
return { status }
}
function unzipFilesFromS3({ status }) {
// do something here to unzip files from s3
return { status, files }
}
function phase4({ status, files }) {
// etc
}
Until the processSomething
finally gets called:
function processSomething({ parameterFromOutputOfUpdateMongoStatus, parameterFromPhase4, parameterFromPhase5 }) {
// Do something here
}
Is this ok? To pass data around like that?
Thank you.