Created
November 9, 2019 00:39
-
-
Save flpms/07f6a3e013a3cbfd70968cf3990c638f to your computer and use it in GitHub Desktop.
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 saveOrderWrapper = (dependencies) => { | |
const { repository, config } = dependencies; | |
const { mongoDB } = repository; | |
const { orderTTLInDays } = config.app; | |
const orderTTL = (millesecondsInADay * orderTTLInDays); | |
const asyncCall = prepareCall(dependencies); | |
const order = async (payload) => { | |
const order = { | |
...payload, | |
}; | |
await asyncCall(); | |
} | |
}; |
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 saveOrderWrapper = ({ | |
repository, | |
cms, | |
getProperty, | |
config, | |
}) => { | |
const { mongoDB } = repository; | |
const { orderTTLInDays } = config.app; | |
const orderTTL = (millesecondsInADay * orderTTLInDays); | |
const asyncCall = prepareCall({ | |
repository, | |
cms, | |
getProperty, | |
config, | |
}); | |
const order = async (payload) => { | |
const order = { | |
...payload, | |
}; | |
await asyncCall(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Destructuring isn't always the right approach. For example, we could have taken this even further, but I think this does make more sense than either of the above:
IMO, this function knows too much about repository and config. There's a bunch of tight coupling here and lots of opportunity to improve things. Generally speaking, if you need to destructure a ton of things, that could be a code smell that your function is trying to do too much.