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
class ParentViewModelClass { | |
func singleSelectionCell(_ title: String) -> FormCellBuildable { | |
return FormCheckmarkCellModel( | |
title: title, selected: false, | |
didSelect: { model in | |
// create single use subscription | |
let _ = self.selectedValue.asObservable().withPrevious(startWith: nil).take(1) | |
.filter { $0.1 != nil }.map { ($0.0, $0.1!) } | |
.subscribe(onNext: { from, to in |
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 RxSwift | |
var disposeBag: DisposeBag! = DisposeBag() | |
var variable: Variable<[Int]>! | |
= Variable<[Int]>([1, 2, 3]) | |
var variableObserver: Observable! = variable.asObservable() | |
var subject: PublishSubject<[Int]>! = PublishSubject<[Int]>() | |
var observable: Observable<[Int]>! | |
func foo() { |
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 v = Variable<[Int]>([1, 2, 3]) | |
let withDiffs = v.asObservable().withDiffs(startingWith: []) | |
.subscribe(onNext: { print("With diffs: \($0)") }) | |
let justDiffs = v.asObservable().diffs(startingWith: []) | |
.subscribe(onNext: { print("Just diffs: \($0)") }) | |
v.value = [1, 3, 4] | |
prints: |
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
// Adapted from original Apple Obj-C sample code | |
import UIKit | |
import CoreText | |
import QuartzCore | |
@IBDesignable | |
class ClippingLabel : UILabel { |
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
// https://gist.github.com/MrAlek/3d1520ca2c5d981489e2 | |
import UIKit | |
enum Direction { | |
case left, right, up, down | |
var pointVector: CGPoint { | |
switch self { | |
case .left: return CGPoint(x: -1, y: 0) |