DisposeOnDestroy

RxJava2 helper to dispose Disposables before leaking stuff

Лицензия

Лицензия

Категории

Категории

RxJava Контейнер Микросервисы Reactive libraries
Группа

Группа

pl.mg6.rxjava2.disposeondestroy
Идентификатор

Идентификатор

core
Последняя версия

Последняя версия

0.1.0
Дата

Дата

Тип

Тип

aar
Описание

Описание

DisposeOnDestroy
RxJava2 helper to dispose Disposables before leaking stuff
Ссылка на сайт

Ссылка на сайт

https://github.com/mg6maciej/DisposeOnDestroy
Система контроля версий

Система контроля версий

https://github.com/mg6maciej/DisposeOnDestroy

Скачать core

Имя Файла Размер
core-0.1.0.pom
core-0.1.0.aar 7 KB
core-0.1.0-sources.jar 1 KB
core-0.1.0-javadoc.jar 261 bytes
Обзор

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/pl.mg6.rxjava2.disposeondestroy/core/ -->
<dependency>
    <groupId>pl.mg6.rxjava2.disposeondestroy</groupId>
    <artifactId>core</artifactId>
    <version>0.1.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/pl.mg6.rxjava2.disposeondestroy/core/
implementation 'pl.mg6.rxjava2.disposeondestroy:core:0.1.0'
// https://jarcasting.com/artifacts/pl.mg6.rxjava2.disposeondestroy/core/
implementation ("pl.mg6.rxjava2.disposeondestroy:core:0.1.0")
'pl.mg6.rxjava2.disposeondestroy:core:aar:0.1.0'
<dependency org="pl.mg6.rxjava2.disposeondestroy" name="core" rev="0.1.0">
  <artifact name="core" type="aar" />
</dependency>
@Grapes(
@Grab(group='pl.mg6.rxjava2.disposeondestroy', module='core', version='0.1.0')
)
libraryDependencies += "pl.mg6.rxjava2.disposeondestroy" % "core" % "0.1.0"
[pl.mg6.rxjava2.disposeondestroy/core "0.1.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
io.reactivex.rxjava2 : rxjava jar 2.0.7

Модули Проекта

Данный проект не имеет модулей.

DisposeOnDestroy

RxJava2 helper to dispose Disposables before leaking stuff

Usage

Observable::disposeOnDestroy(Activity)
Single::disposeOnDestroy(Activity)
Maybe::disposeOnDestroy(Activity)
Completable::disposeOnDestroy(Activity)
class MyActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.my_activity)
        makeApiCall()
    }

    private fun makeApiCall() {
        myRetrofitApi.call()
                .subscribeOn(io())
                .observeOn(mainThread())
                .disposeOnDestroy(this)
                .subscribe(this::displayResults, this::displayError)
    }

    // ...
}

Also works with Fragments from support-v4.

Observable::disposeOnDestroyView(Fragment)
Single::disposeOnDestroyView(Fragment)
Maybe::disposeOnDestroyView(Fragment)
Completable::disposeOnDestroyView(Fragment)
class MyFragment : Fragment() {

    // ...

    private fun onSearchClick(query: String) {
        searchApi.call(query)
                .subscribeOn(io())
                .observeOn(mainThread())
                .disposeOnDestroyView(this)
                .subscribe(this::displayResults, this::displayError)
    }

    // ...
}

See demo module for working examples or some random commit to see how to apply this little lib.

TODO: add examples with logic extracted into plain classes.

Gradle

dependencies {
    compile 'pl.mg6.rxjava2.disposeondestroy:core:0.1.0'
    compile 'pl.mg6.rxjava2.disposeondestroy:support:0.1.0'
}

Версии библиотеки

Версия
0.1.0