Skip to content

Add .materialize() for Single, Maybe, Completable #1982

@M0rtyMerr

Description

@M0rtyMerr

Working with sequence of events instead of elements might be important in some cases. When we want to prevent sequence from completion. Or with RxSwiftExt .elements() and .errros() operators, which is useful in error handling idiom:

let events = source.flatMap { [service] in 
  service.get().asObservable().materialize()
}
.share()
events.elements().bind(to: ...)
events.error().bind(to: ...)

Using single.asObervable().materialize() looks strange for me. It can be cutted to simple single.materialize(). Also we lose trait guarantees, because of cast to Observable.
I can't see any reasons why we can't materialize Single or Maybe.

My suggestion is to add .materialize() to Completable, Maybe and Single. Return type would be Single<Event<Element>>. And .dematerialize() for Single return type would be Maybe<T>

Here is the same issue & PR for RxJava - ReactiveX/RxJava#6278

What do you think @kzaher? Please, share your thoughts. I am ready to contribute :)
Here is a possible implementation - #1970

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions