Closed Zengyonghao closed 3 years ago
like this
val listener = View.OnClickListener { safeOffer(it) }
Does this work?
class ClickEvent(val view: View)
merge(
binding.actionWechat.clicks().map { ClickEvent(binding.actionWechat) },
binding.actionFacebook.clicks().map { ClickEvent(binding.actionFacebook) },
binding.actionTwitter.clicks().map { ClickEvent(binding.actionTwitter) },
binding.actionWhatapp.clicks().map { ClickEvent(binding.actionWhatapp) },
).onEach {
// event.view
}
Does this work?
class ClickEvent(val view: View) merge( binding.actionWechat.clicks().map { ClickEvent(binding.actionWechat) }, binding.actionFacebook.clicks().map { ClickEvent(binding.actionFacebook) }, binding.actionTwitter.clicks().map { ClickEvent(binding.actionTwitter) }, binding.actionWhatapp.clicks().map { ClickEvent(binding.actionWhatapp) }, ).onEach { // event.view }
thanks. This can solve the problem
I want to merge multiple click events, but Flow prevents me from distinguishing the source of the events
merge(binding.actionWechat.clicks(), binding.actionFacebook.clicks(), binding.actionTwitter.clicks(), binding.actionWhatapp.clicks()) .onEach { }