Rx - How to unsubscribe automatically after receiving onNext()?

后端 未结 2 601
逝去的感伤
逝去的感伤 2021-02-19 05:30

How to unsubscribe automatically after receiving onNext() ?

For now I use this code:

rxObservable
.compose(bindToLifecycle()) // unsubscribe automaticall         


        
2条回答
  •  滥情空心
    2021-02-19 06:10

    I think this is what you need:

     rxObservable.compose(bindToLifecycle())
                 .takeFirst(lifecycleEvent -> lifecycleEvent == LifecycleEvent.PAUSE);
    

提交回复
热议问题