Skip to content

Instantly share code, notes, and snippets.

View danielt1263's full-sized avatar

Daniel Tartaglia danielt1263

View GitHub Profile
@danielt1263
danielt1263 / PollContinuously+Rx.swift
Last active February 20, 2024 13:41
The pollContinuously operator is useful if you want to subscribe to an Observable again after it finishes...
//
// PollContinuously+Rx.swift
//
// Created by Daniel Tartaglia on 20 Jun 2023.
// Copyright © 2023 Daniel Tartaglia. MIT License.
//
import RxSwift
extension ObservableType {
//
// ThrottleDebounceLatest.swift
//
// Created by Daniel Tartaglia on 14 Oct 2023.
// Copyright © 2023 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift
//
// UITextViewExtensions.swift
//
// Created by Daniel Tartaglia on 7/20/17.
// Copyright © 2017 Daniel Tartaglia. MIT License.
//
import UIKit
extension UITextField {
@danielt1263
danielt1263 / ClearingDebounceTests.swift
Last active July 21, 2023 16:29
A conditional debounce operator.
class Tests: XCTestCase {
var scheduler: TestScheduler!
var result: TestableObserver<String>!
var disposeBag: DisposeBag!
override func setUp() {
super.setUp()
scheduler = TestScheduler(initialClock: 0, resolution: 0.1)
result = scheduler.createObserver(String.self)
disposeBag = DisposeBag()
@danielt1263
danielt1263 / SharedCache+Rx.swift
Last active June 20, 2023 10:51
I was asked to create a shared cache.
//
// SharedCache+Rx.swift
//
// Created by Daniel Tartaglia on 12 Jun 2021.
// Copyright © 2023 Daniel Tartaglia. MIT License.
//
import RxSwift
extension ObservableType {
@danielt1263
danielt1263 / RetryingTokenNetworkService.swift
Last active June 12, 2023 14:54
The TokenAcquisitionService automatically retry requests if it receives an unauthorized error. Complete with proof that it works correctly.
//
// TokenAcquisitionService.swift
//
// Created by Daniel Tartaglia on 16 Jan 2019.
// Copyright © 2022 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift
@danielt1263
danielt1263 / RetryWhen.swift
Last active April 25, 2023 09:40
I have implemented RetryWhen in Combine.
//
// RetryWhen.swift
// CombineSandbox
//
// Created by Daniel Tartaglia on 9/27/19.
// Copyright © 2019 Daniel Tartaglia. MIT License.
//
import Foundation
import Combine
//
// CLGeocoder+Rx.swift
//
// Created by Daniel Tartaglia on 5/7/16.
// Copyright © 2018 Daniel Tartaglia. MIT License.
//
import RxSwift
import CoreLocation
import Contacts
// uses https://gist.github.com/danielt1263/bd449100764e3166644f7a38bca86c96
import RxSwift
import RxTest
import XCTest
final class ExampleTests: XCTestCase {
func test_merge_second_finishes_faster() {
let scheduler = TestScheduler(initialClock: 0)
let args = scheduler.createObserver(Device.self)
@danielt1263
danielt1263 / AccumulatingDebounce.swift
Last active March 10, 2023 20:02
Created by request. This operator works like the `debounce` operator except it emits all the elements that were created during the wait time.
//
// AccumulatingDebounce.swift
//
// Created by Daniel Tartaglia on 10 Mar 2023.
// Copyright © 2023 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift