Open StefMa opened 6 years ago
I think it's a nice idea. But keep in mind that sendToView()
must be used to wrap any call to a view method if it's called from a lengthy asynchronous operation that might outlive the lifecycle. But there might be view methods that are called in response to an ui event (which implies that a view currently exists) and in response to a lengthy asynchronous operation. Just adding an annotation to the view method would mean that we get warnings in places where sendToView()
is not necessarily required. 🤔
Sometimes we are using
viewOrThrow.doSmthWithTheView()
to send directly something to the view. This is useful if we get a callback from the View (in a onclicklistener) for example. So we don't have to saysendToView { it.doSmthWithTheView() }
.But sometimes we refactore code and oversee se
viewOrThrow
which should be wrapped intosendToView{}
. For that it would be great if we have annotation like@ViewAttached
over the method which says that these method should be only called if a view is attached. With that we can make sure, that we can safely callviewOrThrow.
instead ofsendToView{}
.What do you think?