Coder Social home page Coder Social logo

live's Introduction

Hi there 👋

目前正在找工作,有看上我技艺的,深圳地区请联系我。

live's People

Contributors

listenzz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

live's Issues

检查主线程问题

我写的以下代码, x 时间后执行 xx 操作

        Observable.timer(2000, TimeUnit.MILLISECONDS)
                .compose(Live.bindLifecycle(this))
                .subscribe({
                    LogUtil.d("ok")
                    //....
                }, {
                    LogUtil.e(it)
                })

看起来貌似没有问题,但是执行后,没有任何输出,onNextonError都没有被回调,关键是没有任何报错.

看了下源码,跟踪了一下,原因: Live.java#67 assertMainThread();判断当前线程是否为主线程,不是就报错.而我上述的代码,onNext 执行是不在主线程上的,所以这里抛异常了,但是!onError没有收到这个异常信息!!

解决办法: 在compose(Live.bindLifecycle(this))前加上.observeOn(AndroidSchedulers.mainThread())

望优化异常处理.

进入第二个页面返回数据无法接收

在第一个页面使用,
Observable.create(new ObservableOnSubscribe() {
@OverRide
public void subscribe(ObservableEmitter e) throws Exception {
Thread.sleep(3000);
e.onNext("a");
e.onComplete();
}
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(Live.bindLifecycle(this))
.subscribe(it -> Log.d(TAG, it));
然后调用第二个页面,然后等待发送数据,之后无法接收到上游发送的数据,原因是调用了onComplete()方法,导致considerNotify方法里面的!mDisposable.isDisposed()为false

调用 dispose() 时的问题

验证code:

        val d = Observable.create<Int> {
            for (i in 0..1000) {
                Thread.sleep(500)
                LogUtil.d("it.isDisposed=" + it.isDisposed + ",i=" + i)
                if (it.isDisposed) {
                    break
                }
                it.onNext(i)
            }
            it.onComplete()
        }.subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(Live.bindLifecycle(this))
                .subscribe({
                    LogUtil.d(it)
                }, { it.printStackTrace() })
        bu.postDelayed({
            d.dispose()
        }, 2000)

2s 之后调用 dispose(),不加 .compose(Live.bindLifecycle(this)) 时,效果正常,2s 后会停掉输出,加了之后,onNext()虽然没有被调用,但是 it.isDisposed=false,i= 一直在输出.
我本来是在做下载文件显示进度的功能,但是取消下载一直不生效,取消之后,文件还是在后台下载完了....
调试了好久,才发现是这里的问题.
正常情况我觉得应该是加 Live.bindLifecycle() 之后和没加之前的"表现"应该一直才对.
谢谢.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.