Advertisement
andreashorberg

RefreshButtonModel take 2

Oct 15th, 2019
1,286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.51 KB | None | 0 0
  1. class RefreshButtonModel: ObservableObject {
  2.     @Published var showRotatingButton: Bool = false
  3.     @Published var isRotating: Bool = false
  4.     private var subscriptions: Set<AnyCancellable> = []
  5.  
  6.     init(loadingPublisher: AnyPublisher<Bool, Never>) {
  7.         loadingPublisher
  8.             .sink { isLoading in
  9.                 self.showRotatingButton = isLoading
  10.                 if !isLoading {
  11.                     self.isRotating = false
  12.                 }
  13.         }
  14.         .store(in: &subscriptions)
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement