Skip to content

Commit

Permalink
[Jinsujin/issue-tracker] #28 Refactor: IssueVC 생성 시 필요한 작업을 viewDidLo…
Browse files Browse the repository at this point in the history
…ad대신 Container에서 하도록 변경
  • Loading branch information
bibi6666667 committed Jul 25, 2022
1 parent 3dce5a4 commit 2aa67de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
9 changes: 8 additions & 1 deletion IssueTracker/IssueTracker/Container.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ class Container {
})
})
)
let viewController = IssueViewController(model: model, repo: selectedRepo) // Issue -> Issues
let viewController = IssueViewController(model: model, repo: selectedRepo)
model.requestIssue()
model.updatedIssues = {
DispatchQueue.main.async { [weak viewController] in
viewController?.reloadData()
}
}
viewController.title = "Issues"
return viewController
case .newIssue(let repo):
// MARK: 아래와 같이 파라미터와 completion이 함께 필요한 클로저라면, 클로저를 통해 넘기지 않고 직접 참조해서 넣어줘도 괜찮은지?? (weak self 필요없음)
Expand Down
13 changes: 6 additions & 7 deletions IssueTracker/IssueTracker/Issue/IssueViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,21 @@ final class IssueViewController: UIViewController {
// MARK: ViewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Issues"

setupNavigationBar()
setupViews()
model.requestIssue()
model.updatedIssues = {
DispatchQueue.main.async { [weak self] in
self?.collectionView.reloadData()
}
}

}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.prefersLargeTitles = true
}

func reloadData() {
self.collectionView.reloadData()
}

@objc func touchedSelectButton() {

}
Expand Down

0 comments on commit 2aa67de

Please sign in to comment.