Skip to content

RxJava2.0 - We may need a Observable.createDisposable(...) #4937

@magillus

Description

@magillus

I run into problem when creating Observable with:
Observable.create(new ObservableOnSubscribe())
When new ObservableOnSubscribe implements Disposable it is expected to call dispose() method to release some resources, that is not happening.

Observable created with Observable.create(..) doesn't implement Disposable and the upstream clean up isn't passing through to ObservableOnSubscribe.

I am open to discussion and suggest small change with:
Observable.java add method:

public static <T> Observable<T> createDisposable(DisposableObservableOnSubscribe<T> observableOnSubscribe) {
        return Observable.create(observableOnSubscribe).doOnDispose(observableOnSubscribe::dispose);
    }

with adding new Interface of DisposableObservableOnSubscribe:

public interface DisposableObservableOnSubscribe<T> extends ObservableOnSubscribe<T>, Disposable {

}

Or doing it other way - like I did on: gist

I didn't found something that would solve this use case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions