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
UIApplication.shared.windows.first?.traitCollection.userInterfaceStyle |
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 DisplayGenericCell< DISPLAY_VIEW :UIView> : UICollectionViewCell { | |
var displayView : DISPLAY_VIEW! | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
clipsToBounds = true | |
displayView = DISPLAY_VIEW() |
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
import Dispatch | |
private let coroutineQueue = DispatchQueue(label: "com.swift5.yield", attributes: .concurrent) | |
public class Coroutine<Element>: IteratorProtocol { | |
private let callerReady = DispatchSemaphore(value: 0) | |
private let coroutineReady = DispatchSemaphore(value: 0) | |
private var done: Bool = false | |
private var transportStorage: Element? |
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
// swift-tools-version:5.1 | |
// The swift-tools-version declares the minimum version of Swift required to build this package. | |
import PackageDescription | |
let package = Package( | |
name: "MyLibrary", | |
products: [ | |
// Products define the executables and libraries produced by a package, and make them visible to other packages. | |
.library( | |
name: "MyLibrary", |
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
extension MoviesCollectionView{ | |
func setupRx(){ | |
setupRxCollectionView() | |
setupRxDrivers() | |
} | |
func setupRxCollectionView(){ | |
let dataSubject = PublishSubject<[MoviesSection]>() |
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
import UIKit | |
import RxSwift | |
import RxCocoa | |
public class BehaviorDriver<Element>: NSObject { | |
var behavior: BehaviorRelay<Element>! | |
var driver: Driver<Element> { | |
return behavior.asDriver() | |
} |
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
// Getting a single object | |
Services.api.rx.call(.getMovie(mid)) | |
.subscribe(onSuccess: { completion($0) }) | |
.disposed(by: diposeBag) | |
// Getting a list | |
Services.api.rx.call(.getMovieRelated(mid)) | |
.subscribe(onSuccess: { [weak self] (response:APIResponseMovieList) in | |
self?.movies = response.items() |
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
import UIKit | |
import Alamofire | |
import AlamofireObjectMapper | |
import ObjectMapper | |
typealias APIClosure<K> = (K?)->Void | |
class APIService: NSObject { | |
static let API_KEY_V3 = "SECRET_KEY" |
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
import UIKit | |
import ObjectMapper | |
protocol APIResponse { | |
func items<K>(_ type:K.Type? )->[K] | |
} | |
extension APIResponse{ | |
func items<K>(_ type:K.Type? = nil)->[K]{ | |
return ([self] as? [K]) ?? [] |
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
import UIKit | |
import RxSwift | |
import Alamofire | |
import AlamofireObjectMapper | |
extension Reactive where Base:APIService{ | |
func call<K:APIResponse>(_ endpoint : APIEndpoints) -> Single<K> { | |
return Single<K>.create { single in | |