This file contains hidden or 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
| func viewDidLoad() { | |
| super.viewDidLoad() | |
| self.userObserver = UserObserver() | |
| self.userObserver.rx().subscribeNext { [weak self] user in | |
| self.avatarImageView.setImage(url: user.avatarUrl) | |
| } | |
| } |
This file contains hidden or 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
| class KeychainRepository { | |
| static let instance: KeychainRepository = KeychainRepository() | |
| func save(session session: Session, name: String) | |
| func clear(name name: String) | |
| func fetch(name name: String) -> Session? | |
| func observe(name name: String) -> Observable<Session?> | |
| } |
This file contains hidden or 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
| class AppDelegate { | |
| func observeUserSession() { | |
| let sessionObserver = SessionObserver(name: "my-service") | |
| sessionObserver | |
| .map { $0 != nil } | |
| .distinctUntilChanged() | |
| .subscribeNext { [weak self] authenticated in | |
| if authenticated { | |
| self?.showLogin() |
This file contains hidden or 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
| class StreamViewController: UIViewController { | |
| func viewDidLoad() { | |
| super.viewDidLoad() | |
| self.synchronizeStream() | |
| self.observeStreamTracks() | |
| } | |
| func synchronizeStream() { | |
| // Synchronization logic | |
| } |
This file contains hidden or 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
| // Synchronizing data | |
| apiClient.synchronizeTracks { [weak self] tracks in | |
| self?.tracks = tracks | |
| self?.tableView.reloadData() | |
| } | |
| // Player | |
| func loadTrack(track: Track) { | |
| self.player.instance.loadTrack(track) | |
| self.playerControls.updateWithTrack(track) |
This file contains hidden or 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
| // Offline+API.swift | |
| public extension Offline { | |
| func isTrackOffline(track: Track) -> Bool | |
| func downloadTrackIfNeeded(track: Track, completion: (error: NSError?) -> Void) | |
| } |
This file contains hidden or 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
| // Offline.swift | |
| class Offline { | |
| // MARK: - Internal | |
| internal var storage: Storage | |
| // MARK: - Init |
This file contains hidden or 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
| // Search.swift | |
| class Search { | |
| let player: Player | |
| let storage: Storage | |
| init(player: Player) { | |
| self.player = player | |
| self.storage = Storage(model: "Player") | |
| self.storage.setup() | |
| } |
This file contains hidden or 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
| // Player.swift | |
| class Player { | |
| let storage: Storage | |
| } | |
| // Player+API | |
| extension Player { | |
| func createQueue(tracks: [PlayerTrack]) -> String | |
| } |
This file contains hidden or 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
| // Image Caching framework | |
| class ImageCaching { | |
| func isCached(url: String) -> Bool | |
| func fetchCaching(url: String) throws -> UIImage? | |
| } |