Skip to content

Commit

Permalink
chore/#301 바인딩 함수 네이밍 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaybei committed Aug 23, 2024
1 parent e60d1a0 commit 82757d8
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions KkuMulKum/Source/Home/ViewController/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,23 @@ class HomeViewController: BaseViewController {
viewModel.requestNearestPromise()
viewModel.requestUpcomingPromise()

updateUI()

updateUserInfo()
updateNearestPromise()
updateUpcomingPromise()
setupBinding()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isNavigationBarHidden = true

updateUI()

updateUserInfo()
updateNearestPromise()
updateUpcomingPromise()

viewModel.requestLoginUser()
viewModel.requestNearestPromise()
viewModel.requestUpcomingPromise()

setupBinding()
}


// MARK: - Function

override func setupAction() {
rootView.todayButton.addTarget(
self,
Expand Down Expand Up @@ -197,7 +193,14 @@ private extension HomeViewController {
)
}

func updateUI() {
func setupBinding() {
bindCurrentState()
bindUserInfo()
bindNearestPromise()
bindUpcomingPromise()
}

func bindCurrentState() {
viewModel.currentState.bind { [weak self] state in
DispatchQueue.main.async {
switch state {
Expand All @@ -214,7 +217,7 @@ private extension HomeViewController {
}
}

func updateUserInfo() {
func bindUserInfo() {
viewModel.loginUser.bind { [weak self] _ in
DispatchQueue.main.async {
let data = self?.viewModel.loginUser.value
Expand Down Expand Up @@ -261,7 +264,7 @@ private extension HomeViewController {
}
}

func updateNearestPromise() {
func bindNearestPromise() {
viewModel.nearestPromise.bind { [weak self] _ in
DispatchQueue.main.async {
guard let self = self else { return }
Expand Down Expand Up @@ -300,7 +303,7 @@ private extension HomeViewController {
}
}

func updateUpcomingPromise() {
func bindUpcomingPromise() {
viewModel.upcomingPromiseList.bind { [weak self] _ in
guard let self,
let responseBody = viewModel.upcomingPromiseList.value,
Expand Down

0 comments on commit 82757d8

Please sign in to comment.