Common network stack - #2161
Common network stack#2161tobiasKaminsky wants to merge 4 commits into
Conversation
alperozturk96
left a comment
There was a problem hiding this comment.
I think before continuing we should agree on things I mentioned.
Package order:
/users
/users/model/UserInfoResponse
/users/repository/UserRemoteRepository
/users/UserApi
Also we should add this to the skills.
| interface UserApi { | ||
| @Headers(OCS_API_REQUEST_HEADER) | ||
| @GET(ENDPOINT_USER) | ||
| fun getUser( |
There was a problem hiding this comment.
Since we are starting something new.
Prefixes like get, set should be used for internal data class, POJO object change like setName, getName or getting data from internal db.
and fetch should be used for remote operation thus we can have clear distinction between them.
| interface UserApi { | ||
| @Headers(OCS_API_REQUEST_HEADER) | ||
| @GET(ENDPOINT_USER) | ||
| fun getUser( |
There was a problem hiding this comment.
Why we are exposing non-suspended version of the same function. Library should enforce the consumer to use suspending version of it. Thus we don't create more technical debts, ANRs.
Also library should never expose the suspend function calls without correct threading. This needs to be forced as well.
e.g.
interface UserApi -> this will be internal in the library
class UserRemoteRepository( -> this will be public
private val api: UserApi
) {
suspend fun fetchUser(): OcsKotlinResponse<UserInfoResponse> =
withContext(Dispatchers.IO) {
api.fetchUser("json")
}
}
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
Goal:
To discuss:
PRs:
Files: nextcloud/android#17760
Talk: nextcloud/talk-android#6802
Notes: nextcloud/notes-android#3372
🤖 AI (if applicable)