Skip to content

Instantly share code, notes, and snippets.

View danielt1263's full-sized avatar

Daniel Tartaglia danielt1263

View GitHub Profile
//
// UITextViewExtensions.swift
//
// Created by Daniel Tartaglia on 7/20/17.
// Copyright © 2017 Daniel Tartaglia. MIT License.
//
import UIKit
extension UITextField {
//
// UITableViewExtensions.swift
//
// Created by Daniel Tartaglia on 7/21/17.
// Copyright © 2017 MIT License.
//
import UIKit
@danielt1263
danielt1263 / ViewController.swift
Created August 21, 2018 02:20
Rx DataSource custom implementation example.
//
// Created by Daniel Tartaglia on 4/20/17.
// Copyright © 2017 Daniel Tartaglia. MIT License.
import UIKit
import RxSwift
import RxCocoa
class ViewController: UIViewController {
//
// Filter.swift
//
// Created by Daniel Tartaglia on 8/25/2018.
// Copyright © 2019 Daniel Tartaglia. MIT License.
//
import RxSwift
extension ObservableType {
@danielt1263
danielt1263 / Observables.swift
Last active August 28, 2018 21:31
Experimental idea for binding to views that don't exist yet in viewDidLoad.
//
// Observables.swift
//
// Created by Daniel Tartaglia on 8/13/18.
// Copyright © 2018 Daniel Tartaglia. MIT License.
//
extension ObservableType {
func bind(to observables: Observables<String, E>, withKey key: String) -> Disposable {
return observables.insert(key: key, value: self)
//
// EmitWhile.swift
//
// Created by Daniel Tartaglia on 09/06/2018.
// Copyright © 2021 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift
//
// ObservableEventTransforms.swift
//
// Created by Daniel Tartaglia on 9/22/18.
// Copyright © 2019 Daniel Tartaglia. MIT License.
//
import RxSwift
/**
//
// StallUnless.swift
//
// Created by Daniel Tartaglia on 1 Oct 2018.
// Copyright © 2024 Daniel Tartaglia. MIT License.
//
import RxSwift
extension ObservableType {
//
// Sequence+Scan.swift
//
// Created by Daniel Tartaglia on 10/13/2018.
// Copyright © 2018 Daniel Tartaglia. MIT License.
//
extension Sequence {
public func scan<Result>(_ initialResult: Result, _ nextPartialResult: (Result, Element) throws -> Result) rethrows -> [Result] {

Recipes for Combining Observables in RxSwift

Several operators exist to combine multiple observables into one. This document shows the basics of the various combining operators and shows some more advanced recipes using them.

Combine Latest

The combineLatest operator is used whenever you have two or more observables emitting values, and you want access to the latest value emitted from each of them whenever one of them emits a new value. It can be used, for example, to combine a username and password to make a login request:

func example(username: Observable<String>, password: Observable<String>) {

let credentials: Observable<(String, String)> = Observable.combineLatest(username, password)