You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
addOnFailureListener 이후에 flow가 계속 살아있다는 멘토님의 말씀을 듣고 api 호출에 실패했을 때 취소하는 방식을 알아봤다.
또 awiatClose()가 실행될 때 람다로 전달한 함수가 실행된다는 것 같아서 Log를 찍어봤다.
SearchChatRemoteImpl com.kiwi.kiwitalk D before close callbackFLow
SearchChatRemoteImpl com.kiwi.kiwitalk D getMarkerList failure: com.google.firebase.firestore.FirebaseFirestoreException: Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to SERVER to retrieve the cached documents.)
SearchChatRemoteImpl com.kiwi.kiwitalk D closing callbackFLow
SearchChatRemoteImpl com.kiwi.kiwitalk D getMarkerList failure cancel
onFailureListener 호출 -> cancel() 실행 -> awiatClose() 람다 실행 -> cancel() 이후 코드 실행
순서로 진행됐다.
cencel이 없으면 awaitClose()가 실행되지 않아서 람다가 실행되지 않고 계속 살아있는 것 같았다.
추가로 cancel() 안에 사용한 Exception은 collect 하기 전에 catch()를 사용하면 FlowCollector 형식으로 받을 수 있었고 toResult()로 변환해서 오류를 확인할 수 있었다.
실행 순서는 예시 코드 기준으로 3번과 4번 사이에 값을 받을 수 있었다.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
실행 코드
awaitClose() 내부 코드
addOnFailureListener 이후에 flow가 계속 살아있다는 멘토님의 말씀을 듣고 api 호출에 실패했을 때 취소하는 방식을 알아봤다.
또 awiatClose()가 실행될 때 람다로 전달한 함수가 실행된다는 것 같아서 Log를 찍어봤다.
onFailureListener 호출
->cancel() 실행
->awiatClose() 람다 실행
->cancel() 이후 코드 실행
순서로 진행됐다.
cencel이 없으면
awaitClose()
가 실행되지 않아서 람다가 실행되지 않고 계속 살아있는 것 같았다.추가로 cancel() 안에 사용한 Exception은 collect 하기 전에 catch()를 사용하면 FlowCollector 형식으로 받을 수 있었고 toResult()로 변환해서 오류를 확인할 수 있었다.
실행 순서는 예시 코드 기준으로 3번과 4번 사이에 값을 받을 수 있었다.
Beta Was this translation helpful? Give feedback.
All reactions