RXJava2. Do I need to allocate threads that emit once? (Single, Maybe)

There is a lot in my code Singlelike

Disposable disp = Single.fromCallable(()-> loadData())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(Schedulers.io())
            .subscribe(res-> showInUI(res),
                    throwable -> Log.e(TAG, throwable.getMessage()))
            );

As I understood from the documentation, the difference between Observableand Singleis that Single can respond with an error, never respond, respond with success and emit only once. Now I don’t manage anything, and everything works fine.

So what do I need to do disp.dispose()at all?

+4
source share
1 answer

, , , Single/Observable/Completable.
, , - , .
, (, Activity), NPE . , , / Activity/Screen, .
Observable.

+3

Source: https://habr.com/ru/post/1677682/


All Articles