Last active
April 13, 2022 11:00
-
-
Save zafarivaev/83e63fe48fa41cc287822058bff23b88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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