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 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
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
// 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
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
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
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
var largeTitleView:UIView{ | |
if let navBarSubviews = navigationController?.navigationBar.subviews { | |
for subView in navBarSubviews where NSStringFromClass(type(of: subView)).contains("LargeTitle"){ | |
return subView | |
} | |
} | |
assert(false, "A large title view is expected on viewDidAppear") | |
return UIView() | |
} |
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 | |
public class FactoryCache { | |
public typealias MakerClosure<Item> = ()->Item | |
typealias CacheType = NSCache<NSString, InstanceWrapper> | |
struct CacheWrapper{ | |
var storage: CacheType = NSCache() | |
} | |
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 SwiftUI | |
import AVFoundation | |
struct CameraView: View { | |
// Set up the AVCaptureSession and AVCaptureVideoPreviewLayer | |
let captureSession = AVCaptureSession() | |
let previewLayer = AVCaptureVideoPreviewLayer() | |
let cameraDelegate = CameraDelegate() |