RxSwift icon indicating copy to clipboard operation
RxSwift copied to clipboard

`Infallible` is missing a number of useful extensions

Open rtharston opened this issue 1 year ago • 3 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
  • [x] macOS
  • [ ] tvOS
  • [ ] watchOS
  • [ ] playgrounds

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

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

Xcode version:

13.4.1

Installation method:

  • [x] CocoaPods
  • [ ] Carthage
  • [ ] Git submodules

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

  • [x] 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
  • [x] I have a significant code base

rtharston avatar Aug 08 '22 21:08 rtharston

.debug() is also missing

marcelofabri avatar Oct 13 '22 02:10 marcelofabri

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

freak4pc avatar Oct 13 '22 06:10 freak4pc

combineLatest without providing resultSelector

I implemented that here: https://github.com/ReactiveX/RxSwift/pull/2508

hallee avatar Apr 11 '23 11:04 hallee