@ViewAttached annotation
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 say sendToView { it.doSmthWithTheView() }.
But sometimes we refactore code and oversee se viewOrThrow which should be wrapped into sendToView{}.
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 call viewOrThrow. instead of sendToView{}.
What do you think?
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. 🤔