@@ -22,7 +22,7 @@ public final class HomeViewModel {
2222 struct Output {
2323 let isLoading = CurrentValueSubject < Bool , Never > ( false )
2424 let sections = CurrentValueSubject < [ any HomeCellModel ] , Never > ( [ ] )
25- let showError = PassthroughSubject < ( ) -> Void , Never > ( )
25+ let showError = PassthroughSubject < ( ) -> Void , Never > ( )
2626 }
2727
2828 @Injected var homeService : HomeService
@@ -77,7 +77,7 @@ public final class HomeViewModel {
7777 to: HomeRoute . lottoResult, how: . push( hidesBottomBarWhenPushed: true ) ,
7878 with: [ " round " : homeService. round as Any ] )
7979 }
80-
80+
8181 fetchResult ( )
8282 }
8383 }
@@ -93,7 +93,7 @@ extension HomeViewModel {
9393 output. sections. send ( sections)
9494 } catch {
9595 output. isLoading. send ( false )
96- output. showError. send { [ weak self] in
96+ output. showError. send { [ weak self] in
9797 guard let self else { return }
9898 self . fetch ( )
9999 }
@@ -110,27 +110,29 @@ extension HomeViewModel {
110110 output. sections. send ( sections)
111111 } catch {
112112 output. isLoading. send ( false )
113- output. showError. send { [ weak self] in
113+ output. showError. send { [ weak self] in
114114 guard let self else { return }
115115 self . fetchRecommendation ( )
116116 }
117117 }
118118 output. isLoading. send ( false )
119119 }
120120 }
121-
121+
122122 fileprivate func fetchResult( ) {
123123 let name = userDataManager. user? . name ?? " "
124- var sections : [ any HomeCellModel ] = [ ]
125-
124+ var sections : [ any HomeCellModel ] = [ ]
125+
126126 output. sections. value. forEach { section in
127- if let _ = section as? HomeRecommendationCollectionViewCellModel {
128- sections. append ( HomeRecommendationCollectionViewCellModel ( title: " \( name) 님을 위한 로또 번호 추천 " , state: . needsRecommendation) )
127+ if section as? HomeRecommendationCollectionViewCellModel != nil {
128+ sections. append (
129+ HomeRecommendationCollectionViewCellModel (
130+ title: " \( name) 님을 위한 로또 번호 추천 " , state: . needsRecommendation) )
129131 } else {
130132 sections. append ( section)
131133 }
132134 }
133-
135+
134136 output. sections. send ( sections)
135137 }
136138}
0 commit comments