RxKotlin-调用dispose时进程终止

时间:2019-03-20 04:14:30

标签: android rx-java rx-kotlin

我正在尝试通过rxkotlin上传图像,我的问题是当我在应用程序中关闭屏幕时,由于将订阅添加到我的处置中,上传过程被终止,因此当我的屏幕关闭或破坏时,我将进行处置。由于这个原因,我的工作被终止了,因为无论如何我都需要处置其他东西,否则会导致内存泄漏

npm run build

> webpack-demo@1.0.0 build /Users/test/Desktop/Devolopment/webpack-demo
> webpack --config webpack.config.js

sh: webpack: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! webpack-demo@1.0.0 build: `webpack --config webpack.config.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the webpack-demo@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/test/.npm/_logs/2019-03-20T04_11_16_661Z-debug.log

以这种方式,即使在屏幕被破坏或清除而没有内存泄漏的情况下,还有其他方法可以继续进行这项工作吗?

1 个答案:

答案 0 :(得分:0)

ViewModel与活动/片段生命周期无关,或者仅与它们的配置更改类无关,因为onCleared仅在活动完成后才被调用。因此,请勿将Rx变量放在onCleared上。最好将它们放在onDestroy

override onDestory(){
super.onDestroy()
disposal.dispose()
}