[Feat] #11 - Coordinator 및 Factory(VC && Coordinator) 구현#12
Merged
L-j-h-c merged 12 commits intoTeamRecorDream:developfrom Oct 2, 2022
Merged
[Feat] #11 - Coordinator 및 Factory(VC && Coordinator) 구현#12L-j-h-c merged 12 commits intoTeamRecorDream:developfrom
L-j-h-c merged 12 commits intoTeamRecorDream:developfrom
Conversation
EunHee-Jeong
approved these changes
Oct 2, 2022
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
👻 작업한 내용
전체적으로 Coordinator / Dependency Container / VC Factory / Coordinator Factory를 구현했습니다.
RD-Navigator 모듈 내에 구현했습니다.
Coordinator
CoordinatorBase : 코디네이터가 따르는 protocol 및 최상위 클래스인 BaseCoordinator, 앱의 시작점을 결정해주는 launchInstructor로 구성되어 있습니다.
CoordinatorNavigationController: Coordinator에서도 SwipeBack Gesture와 BackButton action을 인지할 수 있도록 하는 클래스입니다.이 레포를 참고했습니다.
Router: 뷰를 Routing(화면전환)하는 클래스입니다.LaunchInstructor: AppCoordinator에서 사용할 진입점을 결정합니다. 추후 소셜로그인과 온보딩이 생긴다면 유효하게 사용할 수 있습니다. Coordinator에서 각 플로우를 진행하다가 app의 상태가 바뀌면(비회원 -> 자동로그인), LaunchInstructor.configure() 메서드를 실행하여 바뀐 상태를 반영합니다.Coordinators : 실질적으로 화면전환에 사용하는 Coordinator의 구현체들이 존재하는 폴더입니다.
AppCoordinator와MainTabBarCoordinator입니다.AuthCoordinator정도인 것 같습니다. 이유는 뎁스가 2이상인 플로우가 없기 때문에 MainTabBarCoordinator에서 각 화면으로의 화면전환을 모두 담당할 수 있기 때문입니다.Coordinator는ViewModel의PublishRelay를 구독하여 이벤트가 들어오면 화면전환을 진행합니다.showHomeViewController()에서 뷰모델의 middleButtonTapped를 구독하고, 이벤트가 들어온 경우 DreamWriteVC를 띄워주고 있습니다.showDrreamWriteViewController()에서는 viewDidDisappear를 구독하여 화면이 dismiss됨을 코디네이터가 알아차릴 수 있습니다.뷰모델에서는 VC의 action을 구독하여 자신이 가진
middleButtonTapped에 이벤트를 다시 전달하고 있습니다.Factory : 클린 아키텍쳐에서 복잡한 의존성 관리 및 뷰컨트롤러의 생성에 대한 책임을 지니는 클래스입니다.
Dependency Container : 각종 인스턴스의 의존성을 보유하는 Container입니다. 이 클래스를 통해서 원할 때 서로 다른 인스턴스 간의 의존성을 관리해줄 수 있습니다.
스스로가 Factory로 기능하여 Coordinator가 뷰컨트롤러를 생성할 수 있도록 합니다.Coordinator Factory Protocol을 채택하여 Coordinator를 생성할 수 있도록 구현해야 합니다.ViewController Factory Protocol을 채택하여 ViewController를 생성할 수 있도록 구현해야 합니다.레퍼런스
https://medium.com/blacklane-engineering/coordinators-essential-tutorial-part-i-376c836e9ba7
https://pavlepesic.medium.com/flow-coordinator-pattern-on-steroids-a52021e31bfe
🎤 PR Point
ViewModel에 따로 Relay를 빼두는게 좋은 방식인지는 모르겠네요..
클린 아키텍쳐를 하기 위해서 생성할 파일들이 많은데 템플릿을 하나 만드는 것도 좋을 것 같습니다.
📮 관련 이슈