New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pl.mg6.rxjava2.disposeondestroy:core

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pl.mg6.rxjava2.disposeondestroy:core

RxJava2 helper to dispose Disposables before leaking stuff

  • 0.1.0
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

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.

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'
}

FAQs

Package last updated on 18 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc