Rxswift: RxJava alignment ?

Created on 11 Jan 2018  路  3Comments  路  Source: ReactiveX/RxSwift

Hello,

I'm used to RxJava 2 and now trying to use RxSwift, but I notice few differences and wanted to know if some are on purpose or just missing stuff.

  • Completable.complete on java against Completable.empty in swift (for me make more sens complete)
  • Single/Maybe should have asCompletable method
  • onErrorReturn in java against catchErrorJustReturn in swift

Maybe there more I'll find out with time ^^

:warning: Fields below are optional for general issues or in case those questions aren't related to your issue, but filling them out will increase the chances of getting your issue resolved. :warning:

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 (which ones)
  • [*] 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

Most helpful comment

Hi @jaumard ,

We can think about how can we reduce the gap, but I don't think we will match RxJava perfectly, since RxJava also doesn't perfectly match other Rx implementations.

Some of these differences are language differences, some are caused accidentally by different development teams, some are improvements.

We would need to separate each of them and fix the accidental differences which are named better in RxJava.

Completable.complete on java against Completable.empty in swift (for me make more sens complete)

RxJava considers Single, Maybe and Completable as different entities and not a constrained observable sequence. It seems to me that both views are equally valid.

Single/Maybe should have asCompletable method

The reason why we haven't added every possible method is because we wanted to make as orthogonal methods as possible. asCompletable() =asObservable().ignoreElements()`.

onErrorReturn in java against catchErrorJustReturn in swift

I believe RxJava.onErrorReturnItem = RxSwift.catchErrorJustReturn. I don't think our naming is perfect, but I don't think RxJava naming is perfect either.

Naming operators should represent high level operations/concepts IMHO. Using onError in operator name implies a low level event handler (onError), and not high level operation that is being performed (catching and error/exception).

Here are some examples to illustrate my point. It's / vs:

  • Observable.error and not Observable.onError
  • Observable.never and not Observable.dontSendAnyEvent
  • Observable.just and not Observable.onNextAndComplete

For some reason RxJava uses the item nomenclature vs element.
https://en.wikipedia.org/wiki/Sequence

In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed. Like a set, it contains members (also called elements, or terms).

The reason why we've finished with JustReturn is to imply that we are returning a new sequence that contains of just one element (you can also read it as using just operator transparently).

I guess we could have added an operator RxSwift.catchErrorReturn(_ other: Observable<Element>), so RxSwift.catchErrorJustReturn(_ other: Element) would be just a convenience, but I don't think RxSwift.catchErrorReturn(_ other: Observable<Element>) would be used often.

There is a lot Rx implementations out there, so when discussing naming, it would be great to include other ones also, at least RxJs.

All 3 comments

Some more ^^
flatMapObservable to be able from a Single/Maybe/Completable to switch to an observable and the opposite flatMapSingle/flatMapMaybe/flatMapCompletable from an Observable

onErrorResumeNext and onErrorReturn are also missing for PrimitiveSequence
onErrorResumeNext missing from Observable

Hi @jaumard ,

We can think about how can we reduce the gap, but I don't think we will match RxJava perfectly, since RxJava also doesn't perfectly match other Rx implementations.

Some of these differences are language differences, some are caused accidentally by different development teams, some are improvements.

We would need to separate each of them and fix the accidental differences which are named better in RxJava.

Completable.complete on java against Completable.empty in swift (for me make more sens complete)

RxJava considers Single, Maybe and Completable as different entities and not a constrained observable sequence. It seems to me that both views are equally valid.

Single/Maybe should have asCompletable method

The reason why we haven't added every possible method is because we wanted to make as orthogonal methods as possible. asCompletable() =asObservable().ignoreElements()`.

onErrorReturn in java against catchErrorJustReturn in swift

I believe RxJava.onErrorReturnItem = RxSwift.catchErrorJustReturn. I don't think our naming is perfect, but I don't think RxJava naming is perfect either.

Naming operators should represent high level operations/concepts IMHO. Using onError in operator name implies a low level event handler (onError), and not high level operation that is being performed (catching and error/exception).

Here are some examples to illustrate my point. It's / vs:

  • Observable.error and not Observable.onError
  • Observable.never and not Observable.dontSendAnyEvent
  • Observable.just and not Observable.onNextAndComplete

For some reason RxJava uses the item nomenclature vs element.
https://en.wikipedia.org/wiki/Sequence

In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed. Like a set, it contains members (also called elements, or terms).

The reason why we've finished with JustReturn is to imply that we are returning a new sequence that contains of just one element (you can also read it as using just operator transparently).

I guess we could have added an operator RxSwift.catchErrorReturn(_ other: Observable<Element>), so RxSwift.catchErrorJustReturn(_ other: Element) would be just a convenience, but I don't think RxSwift.catchErrorReturn(_ other: Observable<Element>) would be used often.

There is a lot Rx implementations out there, so when discussing naming, it would be great to include other ones also, at least RxJs.

Was this page helpful?
0 / 5 - 0 ratings