Replace callbacks with observables from RxJava

后端 未结 4 1751
醉话见心
醉话见心 2020-12-09 02:17

Im using listeners as callbacks to observe asynchronous operations with Android, but I think that could be great replacing this listeners with RxJava, Im new using this libr

4条回答
  •  一生所求
    2020-12-09 03:09

    Maybe.create(new MaybeOnSubscribe() {
          @Override
          public void subscribe(MaybeEmitter e) throws Exception {
            OnSuccessListener(uri->{
              e.onSuccess(uri));
            })
            .addOnFailureListener(throwable -> {
              e.onError(throwable);
            });
          }
        });
    

提交回复
热议问题