Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

@ViewAttached annotation #139

Open
StefMa opened this issue Dec 13, 2017 · 1 comment
Open

@ViewAttached annotation #139

StefMa opened this issue Dec 13, 2017 · 1 comment

Comments

@StefMa
Copy link
Contributor

StefMa commented Dec 13, 2017

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?

@ghost
Copy link

ghost commented Dec 13, 2017

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

1 participant