8-1. 함수 옮기기
적용 시점
절차
예시
❌Before
const calculateTotalPrice = ({ productPrice, uidUser }) => {
const getDistanceFee = async () => {
const address = await userService.getAddress(uidUser);
// 거리 계산해서 요금 반환하는 로직
return distancefee;
}
const calculateRemoteFee = async () => {
const address = await userService.getAddress(uidUser);
// 격오지인지 확인하는 로직
return remoteFee;
}
const distanceFee = getDistance(uidUser);
const remoteFee = calculateRemoteFee(uidUser);
return distanceFee + remoteFee;
}⭕After
Last updated