Skip to content

Commit

Permalink
[Jinsujin/issue-tracker] #28 Refactor: OptionSelectVC 생성 시 필요한 설정 부분을…
Browse files Browse the repository at this point in the history
… viewDidLoad 대신 Container에서 처리하도록 변경
  • Loading branch information
bibi6666667 committed Jul 25, 2022
1 parent 2aa67de commit da4fa97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 9 additions & 2 deletions IssueTracker/IssueTracker/Container.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Container {
case .repos:
// Repost에 필요한 service조각만 Model에 넣어주기(클로저 방식 사용)
// ReposModelEnvironment로 IssueService의 requestRepos()를 넣어줘야 한다 - completion으로 넘겨줌
// 클로저 사용 시 weak 사용 염두에 두기!!
// 클로저 사용 시 weak 사용 반드시 확인하기!!
let model = ReposModel(environment: .init(requestRepos: { [weak self] completion in
self?.environment.issueService.requestRepos(completion: { result in
completion(result)
Expand Down Expand Up @@ -67,7 +67,14 @@ class Container {
environment.issueService.requestRepositoryMilestones(repo:completion:),
requestRepositoryAssigness:
environment.issueService.requestRepositoryAssigness(repo:completion:)))
return OptionSelectViewController(model: model, option: option, repo: repo)
model.requestOptions(option, repo: repo)
let viewController = OptionSelectViewController(model: model, option: option, repo: repo)
model.updatedOptions = {
DispatchQueue.main.async { [weak viewController] in
viewController?.reloadData()
}
}
return viewController
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class OptionSelectViewController: UIViewController {
super.viewDidLoad()
setupViews()
self.view.backgroundColor = .white
model.requestOptions(option, repo: repository)
bind()

}

private func setupViews() {
Expand All @@ -51,10 +50,8 @@ class OptionSelectViewController: UIViewController {
}
}

private func bind() {
model.updatedOptions = {
self.tableView.reloadData()
}
func reloadData() {
self.tableView.reloadData()
}

private lazy var tableView: UITableView = {
Expand Down

0 comments on commit da4fa97

Please sign in to comment.