Skip to content

Instantly share code, notes, and snippets.

View sauravexodus's full-sized avatar
Open source

Sourav Chandra sauravexodus

Open source
View GitHub Profile
Stubber.register(self.authRepository.signIn) { _ in .just(.failure(error: SignInReactor.ErrorMessage.signInFailed.rawValue)) }
let disposeBag = DisposeBag()
Observable.of(.signIn(email: self.defaultEmail, password: self.defaultPassword))
.delay(1, scheduler: MainScheduler.instance)
.bind(to: self.signInReactor.action)
.disposed(by: disposeBag)
let states = try? self.signInReactor.state.skip(1).take(2).toBlocking(timeout: 5).toArray()
let disposeBag = DisposeBag()
Observable.of(.signIn(email: self.invalidEmail, password: self.defaultPassword))
.delay(1, scheduler: MainScheduler.instance)
.bind(to: self.signInReactor.action)
.disposed(by: disposeBag)
guard let state = try? self.signInReactor.state.skip(1).take(1).toBlocking(timeout: 5).first(), let errorMessage = state?.errorMessage else {
fail("It should emit error state")
import Eureka
open class _SearchablePushRow<T: Equatable, Cell: CellType> : TableSelectorRow<Cell, SearchableViewController<T>> where Cell: BaseCell, Cell: TypedCellType, Cell.Value == T, T: SearchableItem, T: CustomStringConvertible {
public required init(tag: String?) {
super.init(tag: tag)
onCreateControllerCallback = { [weak self] _ in
let controller = SearchableViewController<T>()
controller.searchPlaceholder = self?.searchPlaceholder
return controller
sauravexodus / RelativeDimensioningUsage.swift
Created September 14, 2017 10:42
Usage of Relative Dimensionsing
// Creating CGRects for your UIView frame
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 200.dp, height: 40.dp))
//Creating constraints
imageView.leftAnchor.constaint(equalTo: view.leftAnchor, constant: 16.dp).isActive = true
//Using as a font size
myLabel.font = UIFont.systemFont(ofSize: 13.dp)
sauravexodus / CGFloat+extensions.swift
Created September 14, 2017 10:31
Relative Dimensioning in Swift Manual Layouts
extension CGFloat {
The relative dimension to the corresponding screen size.
let someView = UIView(frame: CGRect(x: 0, y: 0, width: 320.dp, height: 40.dp)
**Warning** Only works with size references from @1x mockups.
sauravexodus / HowToUse.swift
Created August 27, 2017 15:54
How to use RxNuke+Firebase
import RxSwift
import RxCocoa
import RxNuke
import Nuke
// UIImageView object
lazy var myImageView: UIImageView = {
let myImageView = UIImageView()
myImageView.contentMode = .scaleAspectFit
myImageView.translatesAutoresizingMasksIntoConstraints = false
sauravexodus / Nuke+Firebase.swift
Last active August 27, 2017 15:54
An extension to Nuke for progressive image loading. [Required CocoaPods - RxNuke, RxSwift, FirebaseStorage]
import RxNuke
import Nuke
import RxSwift
import Firebase
import RxCocoa
enum ImageVariants: String {
case high = "_high"
case med = "_med"
case low = "_low"