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: UITableViewController { | |
private let githubService: GithubService | |
private var cancellable: AnyCancellable? | |
private var repos: [Repo] = [] { | |
didSet { | |
tableView.reloadData() | |
} |
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
private func fetchRepos(matching query: String) { | |
githubService | |
.search(matching: query) | |
.replaceError(with: []) | |
.subscribe(on: DispatchQueue.global()) | |
.receive(on: OperationQueue.main) | |
.sink { repos in print("count:", repos.count) } | |
} |
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
let subject = CurrentValueSubject<String, Never>("Hello") | |
subject.sink { value in print(value) } | |
subject.send("World") |
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
private func fetchRepos(matching query: String) { | |
githubService | |
.search(matching: query) | |
.replaceError(with: []) | |
.subscribe(on: DispatchQueue.global()) | |
.receive(on: OperationQueue.main) | |
.assign(to: \.repos, on: self) | |
} |
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
@Published private var query: String = "" | |
private func fetchRepos(matching query: String) { | |
$query.flatMap { | |
self.githubService | |
.search(matching: $0) | |
.replaceError(with: []) | |
} | |
.subscribe(on: DispatchQueue.global()) | |
.receive(on: OperationQueue.main) |
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 BackgroundTasks | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
BGTaskScheduler.shared.register( | |
forTaskWithIdentifier: "pl.snowdog.example.refresh", | |
using: DispatchQueue.global() |
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
func applicationDidEnterBackground(_ application: UIApplication) { | |
scheduleAppRefresh() | |
} | |
private func scheduleAppRefresh() { | |
do { | |
let request = BGAppRefreshTaskRequest(identifier: "pl.snowdog.example.refresh") | |
request.earliestBeginDate = Date(timeIntervalSinceNow: 3600) | |
try BGTaskScheduler.shared.submit(request) | |
} catch { |
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 BackgroundTasks | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
BGTaskScheduler.shared.register( | |
forTaskWithIdentifier: "pl.snowdog.example.train", |
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
// | |
// PagerView.swift | |
// | |
// Created by Majid Jabrayilov on 12/5/19. | |
// Copyright © 2019 Majid Jabrayilov. All rights reserved. | |
// | |
import SwiftUI | |
struct PagerView<Content: View>: View { | |
let pageCount: Int |
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
// | |
// BottomSheetView.swift | |
// | |
// Created by Majid Jabrayilov | |
// Copyright © 2019 Majid Jabrayilov. All rights reserved. | |
// | |
import SwiftUI | |
fileprivate enum Constants { | |
static let radius: CGFloat = 16 |