Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doubt #16

Closed
theapache64 opened this issue Apr 17, 2020 · 5 comments
Closed

Doubt #16

theapache64 opened this issue Apr 17, 2020 · 5 comments

Comments

@theapache64
Copy link

First of all, awesome repository. Got a lot to learn in it. 😃

I've a doubt in your code.

Here,

@MainThread
protected abstract suspend fun fetchFromRemote(): Response<REQUEST>
,

Why did you marked fetchFromRemote with @MainThread ? Should it be called from WorkerThread? 🤔

@PatilShreyas
Copy link
Owner

These annotations don't do much. They're like the comment to indicate which thread the function should be called from. This function is already suspend. We're running flow on IO thread. That's why it doesn't matters too much here.

@theapache64
Copy link
Author

theapache64 commented Apr 17, 2020 via email

@PatilShreyas
Copy link
Owner

It's not intentional. Just annotated it with @mainthread as convention (so many repos with same functionality were annotated it with @mainthread)

@DanteAndroid
Copy link

DanteAndroid commented Sep 10, 2020

@PatilShreyas Hi, obviously suspend fun should not be annotated with @MainThread. Never heard of this kind of convention.

@PatilShreyas
Copy link
Owner

PatilShreyas commented Sep 10, 2020

Hi, @DanteAndroid basically these annotations don't do much, they're like a comment to indicate which thread the function should be called from. This prevents the error of calling a function from other thread. Here, it means this function should be called from the main thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants