SingleLiveEvent (LiveData) with multi observers

UPDATE

⚠️Sorry, This article is not recommended!! Do not use this!!⚠️

SingleLiveEvent has a problem that it’s restricted to one observer.

I created NEW SingleLiveEvent which can be observed multi observers in a simple way. This is easier than Event which is mentioned in this article.

(Sorry, it’s bad class name🙇)

Using this new class is just the same using SingleLiveEvent.

val event = SingleLiveEvent2<String>()// Both Observer is working
viewModel.event.observe(this, Observer {
// ...
})
viewModel.event.observe(this, Observer {
// ...
})

As you can see, It’s easy to use.