Skip to content

Commit

Permalink
refactor: 탭바 중복 호출 방지
Browse files Browse the repository at this point in the history
  • Loading branch information
chansooo committed Jul 17, 2024
1 parent f7fdc16 commit bd69c19
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Projects/Features/Home/Sources/Presentation/TabRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ public final class MainTabRouter: Router, ObservableObject {
}

public func start() {
setupTabChangeListener()
bindTabChanged()
}

public func switchToTab(_ tab: MainTab) {
print("switchToTab: \(tab)")
childRouters = []
switch tab {
case .recommend:
Expand All @@ -64,9 +63,9 @@ public final class MainTabRouter: Router, ObservableObject {
}
}

private func setupTabChangeListener() {
private func bindTabChanged() {
$selectedTab
// .removeDuplicates()
.removeDuplicates()
.sink { [weak self] newTab in
self?.switchToTab(newTab)
}
Expand Down

0 comments on commit bd69c19

Please sign in to comment.