ThirtyInch icon indicating copy to clipboard operation
ThirtyInch copied to clipboard

@ViewAttached annotation

Open StefMa opened this issue 8 years ago • 1 comments

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?

StefMa avatar Dec 13 '17 10:12 StefMa

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. 🤔

ghost avatar Dec 13 '17 10:12 ghost