Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1025

Consider returning Single instead of Observable for RxJava1CrudRepository.findOne(…)

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Repositories
    • Labels:
      None

      Description

      RxJava1CrudRepository returns Observable for zero-or-one-element methods such as findOne. We choosed Observable because it allows empty usage without terminating with an error signal. Single is the only type in RxJava 1 that expresses a single-element nature but it requires a single element to complete. Empty completion emits a NoSuchElementException error signal.

      Single is, however, the appropriate return type using RxJava 1 (due to its limited types). Single plays well with other integrations such as WebFlux because Single is a single-element type and Observable a multi-element type. Users would be required to convert from Observable to Single.

      Users of RxJava 2 can use Maybe which is the correct type for zero-or-one element results.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mp911de Mark Paluch
              Reporter:
              mp911de Mark Paluch
              Last updater:
              Mark Paluch
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: