issues
search
kiwi1023
/
iOS-Mongsil
몽실 - 두루뭉술한 하루의 감정 기록, 하루한장 명언 iOS.ver
4
stars
2
forks
source link
UseCase에서 Combine을 사용한 Return 타입 수정필요
#1
Closed
Groot-94
closed
1 year ago
Groot-94
commented
1 year ago
문제 상황
초기에 설정한 useCase read 함수의 return 타입은 [Diary] 타입이였으나, 추후에 Remote DB 사용 시 비동기로 데이터를 전달받기 때문에 비동기로 처리해야 하는 문제
Groot-94
commented
1 year ago
시도
Combine을 사용해서 비동기 처리를 하기로 결정했기 때문에 Combine의 어떤 타입으로 값을 전달할 지 회의
처음엔 구독이 가능한 Publisher 타입의 Published를 사용하려고 했지만 지식이 부족하다 느껴서 각자 학습을 한 후 회의를 진행.
해결
Repository에서 값을 보낼 때 값의 비동기 처리와 Error 처리가 가능한 Future 타입을 사용하기로 결정.
실제로 값을 리턴하는 형식은 외부에서 값을 전달하지 못하고, 여러 클라이언트에서 로직변경 없이 전달받을 수 있는 AnyPublisher 타입 사용하기로 결정
https://developer.apple.com/documentation/combine/anypublisher
문제 상황