-
Notifications
You must be signed in to change notification settings - Fork 0
[Refactor] Repository 및 ViewModel 코드 리팩토링 #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
| @MainActor | ||
| func send(_ action: Action) | ||
|
|
||
| @MainActor | ||
| func reduce(state: inout State, action: Action) -> Effect<Action> | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
View로부터 액션을 전달받는 send(_:) 메서드와 기존 상태를 변경하고 새로운 이펙트를 반환하는 reduce(state:action:) 메서드를 메인 액터(메인 쓰레드)에서 안전하게 동작하도록 수정했습니다.
| @MainActor @Observable | ||
| final class MainViewModel: Reducer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
화면에서 입력받은 액션을 처리해서 화면의 상태를 업데이트 하는 역할을 담당하는 ViewModel이 메인 액터(메인 쓰레드)에서 안전하게 동작되도록 수정했습니다.
| Task.detached { [weak self] in | ||
| let newAction = await action() | ||
| await self?.send(newAction) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사이드 이펙트(비동기 처리)가 메인 액터의 격리에서 벗어난 상태에서 처리되도록 수정했습니다.
|
|
||
| import Foundation | ||
|
|
||
| enum FirebasePath { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xxAPI 로 네이밍해도 좋을 것 같아요
xxEndpoint
|
|
||
| enum FirebasePath { | ||
| case links(userID: String) | ||
| case folders(userID: String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case folders(userID: String)
case folder(userID: String, folderID: String)
| /// 1. Folder 문서 참조 생성 | ||
| // TODO: 후에 testUser를 실제 로그인 된 유저로 변경 예정 | ||
| let folderDocRef = db.collection("users/testUser/folders").document() | ||
| let path = FirebasePath.folders(userID: "testUser").path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
케이스가 다양하기 때문에 네이밍을 좀 더 구체적으로 하면 좋을 것 같아요
f-lab-barry
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Endpoint 케이스 정리만 되면 좋을 것 같아요~



#️⃣ 연관된 이슈
📝 작업 내용