RxSwiftCommunity / RxSwiftExt

A collection of Rx operators & tools not found in the core RxSwift distribution
MIT License
1.33k stars 213 forks source link

mapToVoid #256

Closed asam139 closed 3 years ago

asam139 commented 3 years ago

Name and description

Add mapToVoid to map any observable type to void.

Motivation for inclusion

I am tired to see map { _ in } in the code

Example of use

myObserver.mapToVoid() in place of myObserver.map { _ in }

Code

public extension ObservableType { 
    func mapToVoid() -> Observable<Void> {
        return map { _ in }
    }
}
freak4pc commented 3 years ago

Hey @asam139 - I appreciate the sentiment, and we actually have this operator in our own codebase. However, it feels a bit too opinionated from one hand, and too trivial on the other hand.

Meaning, it is not helpful or wanted for everyone, but it takes a second to add it if you're interested (similarly to mapTrue(), mapFalse(), mapOptional() and other tidbits we like and use in our code base).

WDYT ?

asam139 commented 3 years ago

Ok, you've convinced me 🤣, I will add to my own extensions.