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 Foundation | |
protocol Refreshable { | |
associatedtype DataType | |
func refresh(with data: DataType) | |
} | |
protocol AutoRefreshable: AnyObject, Refreshable { | |
var timer: Timer? { get set } | |
var dataSource: (() -> DataType)? { get set } |
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 Foundation | |
fileprivate let userDefaults = UserDefaults.standart | |
fileprivate let userDefaultsDomain = Bundle.main.bundleIdentifier ?? "" | |
fileprivate extension String { | |
var appendingAppDomain: String { | |
"\(userDefaultsDomain).\(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
import UIKit | |
protocol NibLoadable where Self: UIView { | |
static var nibName: String { get } | |
} | |
extension NibLoadable { | |
static var nibName: String { String(describing: Self.self) } | |
static var nib: UINib { UINib(nibName: Self.nibName, bundle: Bundle(for: Self.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
import UIKit | |
extension UIStoryboard { | |
func instantiateViewController<Type: UIViewController>(of type: Type.Type) -> Type { | |
instantiateViewController(withIdentifier: String(describing: type)) as! Type | |
} | |
} |
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 Foundation | |
class Throttle { | |
private let queue: DispatchQueue | |
private let delay: Double | |
private var delayedBlock: (() -> Void)? | |
private var cancelBlock: (() -> Void)? | |
private var timer: DispatchSourceTimer? | |
private var isReady = true | |
private var hasDelayedBlock: Bool { delayedBlock != nil } |
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 Foundation | |
class Debounce { | |
private let queue: DispatchQueue | |
private let delay: Double | |
private var workItem: DispatchWorkItem? | |
private var cancelBlock: (() -> Void)? | |
init(queue: DispatchQueue, delay: Double) { | |
self.queue = queue |
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
// | |
// ExtensionURLRequest.swift | |
// | |
// Created by Abhishek Maurya on 16/07/20. | |
// Copyright © 2020. All rights reserved. | |
// | |
import Foundation | |
extension URLRequest { |