ReactiveX / RxSwift

Reactive Programming in Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Infallible` is missing a number of useful extensions

rtharston opened this issue · comments

Short description of the issue:

The new Infallible is useful when you know your observable won't have errors, but in some cases you have to resort to using Observable to do something Infallible should be able to do, or to simply remove some boilerplate.

Expected outcome:

Use on of the following methods on an Infallible:

  • combineLatest without providing resultSelector
  • combineLatest on a Collection/Sequence
  • distinctUntilChanged on Equatable type (the Observable extension is where Element: Equatable, but for Infallible it is where Element: Comparable)
  • .observe(on:)

What actually happens:

Compiler errors

Self contained code example that reproduces the issue:

// Error: "Missing argument for parameter 'resultSelector' in call"
Infallible.combineLatest(infallibleOne, infallibleTwo)

// Error: "Missing argument for parameter #2 in call"
// because the compiler thinks you are trying to use combineLatest(_:_:resultSelector)
Infallible.combineLatest(arrayOfBools.map { Infallible.just($0) }) 

// Error: "Referencing instance method 'distinctUntilChanged()' on 'InfallibleType' requires that 'ConversationAppActivity' conform to 'Comparable'"
someInfallible.distinctUntilChanged()

// Error: "Value of type 'Infallible<ConversationAppActivity>' has no member 'observe'"
someInfallible.observe(on: MainScheduler.asyncInstance)

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

6.5.0

Platform/Environment

  • iOS
  • macOS
  • tvOS
  • watchOS
  • playgrounds

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

  • easy, 100% repro
  • sometimes, 10%-100%
  • hard, 2% - 10%
  • extremely hard, %0 - 2%

Xcode version:

13.4.1

Installation method:

  • CocoaPods
  • Carthage
  • Git submodules

I have multiple versions of Xcode installed:
(so we can know if this is a potential cause of your issue)

  • yes (13.4.1, 14 beta)
  • no

Level of RxSwift knowledge:
(this is so we can understand your level of knowledge
and formulate the response in an appropriate manner)

  • just starting
  • I have a small code base
  • I have a significant code base

.debug() is also missing

@marcelofabri Good point as well!
I'm happy to take a PR for some of these.

combineLatest without providing resultSelector

I implemented that here: #2508