LiveEventBus icon indicating copy to clipboard operation
LiveEventBus copied to clipboard

在fragment里调用observe 是不能感应生命周期的吗

Open s472231093 opened this issue 6 years ago • 3 comments

在fragment里调用observe 是不能感应生命周期的 只能在activity里能自动感应生命周期是吗,那这样说fragment里只能observeForever来手动取消了是么

s472231093 avatar Apr 26 '19 07:04 s472231093

Fragment可以感知生命周期,只要是LifecycleOwner的子类都可以

JeremyLiao avatar Apr 27 '19 01:04 JeremyLiao

好的 感谢你 我的理解是 fragment也是在onDestroy 后才是非激活状态 像isHidden setUserVisibleHint 是激活状态是么

------------------ 原始邮件 ------------------ 发件人: "Jeremy Liao"[email protected]; 发送时间: 2019年4月27日(星期六) 上午9:50 收件人: "JeremyLiao/LiveEventBus"[email protected]; 抄送: "小泽玛莉嗷丶"[email protected]; "Author"[email protected]; 主题: Re: [JeremyLiao/LiveEventBus] 在fragment里调用observe 是不能感应生命周期的吗 (#41)

Fragment可以感知生命周期,只要是LifecycleOwner的子类都可以

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

s472231093 avatar Apr 28 '19 01:04 s472231093

是的,fragment会在destroy的时候调用performDestroy,然后用LifecycleRegistry去remove Observer

JeremyLiao avatar Apr 28 '19 02:04 JeremyLiao