Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Tartaglia danielt1263

  • Haneke Design
  • Tampa, FL
View GitHub Profile
View SKPhysicsWorld+Rx.swift
//
// SKPhysicsWorld+Rx.swift
//
// Created by Daniel Tartaglia on 21 Jan 2019.
// Copyright © 2019 Daniel Tartaglia. MIT License.
//
import RxSwift
import SpriteKit
@danielt1263
danielt1263 / RetryingTokenNetworkService.swift
Last active Jul 13, 2021
The TokenAcquisitionService automatically retry requests if it receives an unauthorized error. Complete with proof that it works correctly.
View RetryingTokenNetworkService.swift
//
// RetryingTokenNetworkService.swift
//
// Created by Daniel Tartaglia on 16 Jan 2019.
// Copyright © 2019 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift
View AcceptRejectItems.swift
//
// AcceptRejectItems.swift
//
// Created by Daniel Tartaglia on 9 Jan 2019.
// Copyright © 2019 Daniel Tartaglia. MIT License
//
import RxSwift
struct Input {
View ThrottleUnlessChanged.swift
//
// ThrottleUnlessChanged.swift
//
// Created by Daniel Tartaglia on 6 Jan 2019.
// Copyright © 2020 Daniel Tartaglia. MIT License.
//
import RxSwift
public extension ObservableType where Element: Equatable {
View RxCache.swift
//
// RxCache.swift
//
// Created by Daniel Tartaglia on 12/20/18.
// Copyright © 2018 Daniel Tartaglia. MIT License.
//
import RxSwift
final class Cache<Key: Hashable, State> {
View Combining Recipes.md

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)
View Sequence+Scan.swift
//
// 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] {
View StallUnless.swift
// StallUnless.swift
//
// Created by Daniel Tartaglia
// Copyright © 2017 Daniel Tartaglia. MIT License.
import RxSwift
extension ObservableType {
/**
View ObservableEventTransforms.swift
//
// ObservableEventTransforms.swift
//
// Created by Daniel Tartaglia on 9/22/18.
// Copyright © 2019 Daniel Tartaglia. MIT License.
//
import RxSwift
/**
View EmitWhile.swift
//
// EmitWhile.swift
//
// Created by Daniel Tartaglia on 09/06/2018.
// Copyright © 2019 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift