I have and Android app with the view class (Fragment
, Activity
) observing its ViewModel
.
The ViewModel
exposes methods such as getUserName
which returns Observable<String>
. Although maybe there is a possibility to find a better name (maybe observeUserName
), I'm happy with the current one - it is quite explanatory.
However, here starts the hard part: ViewModel
also can tell the view to perform some operation - for example close itself, pop backstack etc. For this case ViewModel
defines following method (and corresponging Subject
):
class ViewModel {
// other methods, fields
// ViewModel can call returnToPreviousScreen.onComplete()
CompletableSubject returnToPreviousScreen = CompletableSubject.create();
Completable returnToPreviousScreen() { return returnToPreviousScreen; }
}
In my opinion, the method's name is terrible. Hovewer I can not find anything better. Something like observeWhenToReturnToPreviousScreen
is maybe more explanatory but hard to read.
So, are there any recommendations or maybe commonly used practices for naming such methods?