I have a network change notifier class based on ConnectivityManager.NetworkCallback
and i want to update some fields when network is available;
override fun onAvailable(network: Network?) {
super.onAvailable(network)
val db = StoreDatabase.getInstance(context)
val stores = db.createStores()
val disposable = stores.insertStore(Stores(storeName = "testOnAvailableNetInsertions", status
= AppConstants.Database.SYNC_FAIL))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io()).subscribeWith(object : DisposableCompletableObserver() {
override fun onComplete() {
if (!isDisposed)
dispose()
}
override fun onError(e: Throwable) {
if (!isDisposed)
dispose()
}
}).dispose()
Is it okay to call dispose at the end of the method, or do i have to dispose that variable somewhere else, and this is my Dao;
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertStore(stores: Stores): Completable