Skip to content

Instantly share code, notes, and snippets.

View jordanebelanger's full-sized avatar
🚊

Jordane Belanger jordanebelanger

🚊
  • Montreal, Quebec
View GitHub Profile
import Foundation
enum Nullable<Value: Codable>: Codable {
case some(_ value: Value)
case null
init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if container.decodeNil() {
self = .null
@jordanebelanger
jordanebelanger / Single+Result.swift
Created June 7, 2018 20:07
Generically create an RxSwift Single observable from any Alamofire's Result type based asynchronous callback function.
import RxSwift
import Alamofire
extension Single {
static func make<T>(from resultFn: @escaping (@escaping (Result<T>) -> Void) -> Void) -> Single<T> {
return Single<T>.create { sub in
resultFn { result in
switch result {
case .success(let value):
sub(SingleEvent.success(value))
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
if (scrollView.scrollDirectionX == ScrollDirectionRight) {
//Do something with your views etc
}
if (scrollView.scrollDirectionY == ScrollDirectionUp) {
//Do something with your views etc
}
}