ground-android: [Code health] Verify exceptions are either wrapped or handled in all Rx streams

We can rename Result to something like ValueOrError, and wrap the value at the source, obviating the need to wrap/unwrap at arbitrary steps in the stream.

@scolsen FYI.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (5 by maintainers)

Most upvoted comments

@scolsen, I discussed this with former teammates at FAO today (@cdanielw, @lpaolini) who work extensively with RxJS in SEPAL, and consensus is that it’s better to wrap and unwrap in some intermediate object to represent errors as a value rather than at stream level (as we have now), rather than to rely on side-effects on the inner stream, e.g.:

https://github.com/google/ground-android/blob/fd1324aa8e59159c9941c5dfab6c7c082cff0b6f/gnd/src/main/java/com/google/android/gnd/ui/projectselector/ProjectSelectorViewModel.java#L62-L67

My guess is that with some additional syntactic sugar and clearer naming we can make this more self-documenting / obvious without sacrificing FRP “purity”.

The syntax is also less verbose than the above proposed example, which may be an added bonus here.