Skip to content
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

Router를 정의했습니다. #17

Merged
merged 9 commits into from
Jul 23, 2024
Merged

Router를 정의했습니다. #17

merged 9 commits into from
Jul 23, 2024

Conversation

GeonH0
Copy link
Collaborator

@GeonH0 GeonH0 commented Jul 21, 2024

화면 이동, 의존성 주입을 다른 곳에서 관리하기 위해 라우터를 도입했습니다.

  • 각각 화면의 의존성을 Router에서 주입시켜 줍니다.
  • 화면의 push를 Router에서 적용해서 관리 합니다.
  • Drawable 프로토콜은 화면 전환에 사용될 수 있는 뷰 컨트롤러를 추상화합니다
  • SceneDelegate에서 Router 인스턴스를 생성하고, 이를 통해 초기 화면을 설정합니다.
  • MainTabBarController를 Router를 통해 초기화하여 의존성을 주입받도록 변경했습니다.

Comment on lines 52 to 68
let baseNetworkService = BaseNetworkService()
let recipeFetchService = RecipeFetchServiceImpl(networkService: baseNetworkService)
let feedListRepository = FeedListRepositoryImpl(networkService: recipeFetchService)
let searchFeedRepository = SearchFeedRepositoryImpl(networkService: recipeFetchService)
let fetchFeedListUseCase = FetchFeedListUseCaseImpl(repository: feedListRepository)
let searchFeedListUseCase = SearchFeedListUseCaseImpl(repository: searchFeedRepository)
let recipeListInteractor = RecipeListInteractorImpl(
fetchFeedListUseCase: fetchFeedListUseCase,
searchFeedListUseCase: searchFeedListUseCase
)
let recipeListRouter = RecipeListRouterImpl(router: self)
let recipeListVC = RecipeListViewController(
interactor: recipeListInteractor,
router: recipeListRouter
)
recipeListInteractor.delegate = recipeListVC
return recipeListVC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let baseNetworkService = BaseNetworkService()
let recipeFetchService = RecipeFetchServiceImpl(networkService: baseNetworkService)
let feedListRepository = FeedListRepositoryImpl(networkService: recipeFetchService)
let searchFeedRepository = SearchFeedRepositoryImpl(networkService: recipeFetchService)
let fetchFeedListUseCase = FetchFeedListUseCaseImpl(repository: feedListRepository)
let searchFeedListUseCase = SearchFeedListUseCaseImpl(repository: searchFeedRepository)
let recipeListInteractor = RecipeListInteractorImpl(
fetchFeedListUseCase: fetchFeedListUseCase,
searchFeedListUseCase: searchFeedListUseCase
)
let recipeListRouter = RecipeListRouterImpl(router: self)
let recipeListVC = RecipeListViewController(
interactor: recipeListInteractor,
router: recipeListRouter
)
recipeListInteractor.delegate = recipeListVC
return recipeListVC
let recipeListInteractor = RecipeListInteractorImpl(
fetchFeedListUseCase: FetchFeedListUseCaseImpl(
repository: FeedListRepositoryImpl(
networkService: RecipeFetchServiceImpl(
networkService: BaseNetworkService()
)
)
),
searchFeedListUseCase: SearchFeedListUseCaseImpl(
repository: SearchFeedRepositoryImpl(
networkService: RecipeFetchServiceImpl(
networkService: BaseNetworkService()
)
)
)
)
let recipeListRouter = RecipeListRouterImpl(router: self)
let recipeListVC = RecipeListViewController(
interactor: recipeListInteractor,
router: recipeListRouter
)
recipeListInteractor.delegate = recipeListVC
return recipeListVC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굳이 상수로 갖지 않고 바로 주입해도 될 것 같아요.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드 참고해서 다른 디펜던시들도 수정부탁드려요~

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[e4b3115] 수정했습니다

}

func navigateToRecipeDetail(from viewController: UIViewController, recipeID: Int) {
let detailVC = router.createRecipeDetailDependencies(recipeID: recipeID)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createRecipeDetailDependencies 레시피 디테일의 디펜던시를 만든다는 함수인데 VC가 리턴값인게 어색해요.
makeRecipeDetailViewController 정도로 해도 괜찮지 않을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[9c07a9b] 수정했습니다

Copy link

@f-lab-barry f-lab-barry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create~~~~Dependencies 네이밍만 다시 고민해서 수정부탁드려요.

@GeonH0 GeonH0 merged commit 6632383 into main Jul 23, 2024
1 check passed
Copy link

@GeonH0 GeonH0 deleted the feature/Router branch September 12, 2024 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants