Skip to content

Instantly share code, notes, and snippets.

@zafarivaev
Last active April 13, 2022 11:00
Show Gist options
  • Save zafarivaev/83e63fe48fa41cc287822058bff23b88 to your computer and use it in GitHub Desktop.
Save zafarivaev/83e63fe48fa41cc287822058bff23b88 to your computer and use it in GitHub Desktop.
import UIKit
import Combine
...
class ViewController: UIViewController {
...
private func bindStateToTitle() {
self.$state
// 1
.receive(on: DispatchQueue.main)
// 2
.map { $0.rawValue }
// 3
.handleEvents(receiveOutput: { [weak self] stateString in
self?.navigationItem.title = stateString
})
.sink { _ in }
.store(in: &cancellables)
}
private func bindAvatarToImageView() {
...
}
private func getAvatarFromTheServer() -> AnyPublisher<UIImage, Error> {
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment