We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在内部LiveData有值的情况下,Activity#onCreate方法里订阅事件,并立即发送事件,此时将收不到任何回调,代码如何:
Activity#onCreate
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LiveEventBus.get("test").post("value1"); //保证内部LiveData有值 LiveEventBus.<String>get("test").observe(this, new Observer<String>() { @Override public void onChanged(String value) { Log.e("LJX", "value=" + value); } }); LiveEventBus.get("test").post("value2"); } }
此时将收不到任何回调,查看源码后发现,是被ObserverWrapper#preventNextEvent拦截了,该字段本意应该是拦截粘性事件,但在这种情况下,却会拦截订阅后的事件
ObserverWrapper#preventNextEvent
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在内部LiveData有值的情况下,
Activity#onCreate
方法里订阅事件,并立即发送事件,此时将收不到任何回调,代码如何:此时将收不到任何回调,查看源码后发现,是被
ObserverWrapper#preventNextEvent
拦截了,该字段本意应该是拦截粘性事件,但在这种情况下,却会拦截订阅后的事件The text was updated successfully, but these errors were encountered: