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...
View PollContinuously+Rx.swift
//
// PollContinuously+Rx.swift
//
// Created by Daniel Tartaglia on 20 Jun 2023.
// Copyright © 2023 Daniel Tartaglia. MIT License.
//
import RxSwift
extension ObservableType {
View ThrottleDebounceLatest.swift
//
// ThrottleDebounceLatest.swift
//
// Created by Daniel Tartaglia on 14 Oct 2023.
// Copyright © 2023 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift
View UITextView+Extensions.swift
//
// 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.
View ClearingDebounceTests.swift
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.
View SharedCache+Rx.swift
//
// 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.
View RetryingTokenNetworkService.swift
//
// 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.
View RetryWhen.swift
//
// RetryWhen.swift
// CombineSandbox
//
// Created by Daniel Tartaglia on 9/27/19.
// Copyright © 2019 Daniel Tartaglia. MIT License.
//
import Foundation
import Combine
View CLGeocoder+Rx.swift
//
// CLGeocoder+Rx.swift
//
// Created by Daniel Tartaglia on 5/7/16.
// Copyright © 2018 Daniel Tartaglia. MIT License.
//
import RxSwift
import CoreLocation
import Contacts
View Tests.swift
// 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.
View AccumulatingDebounce.swift
//
// AccumulatingDebounce.swift
//
// Created by Daniel Tartaglia on 10 Mar 2023.
// Copyright © 2023 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift