CryptoTweets | 📰🥇 | Android library
kandi X-RAY | CryptoTweets Summary
kandi X-RAY | CryptoTweets Summary
Sample app displaying cryptocurrency related tweets.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of CryptoTweets
CryptoTweets Key Features
CryptoTweets Examples and Code Snippets
Community Discussions
Trending Discussions on CryptoTweets
QUESTION
Is background threading managed automatically with PagingData
as it is with PagedList
, and then returned on the main thread?
From the logs below, it appears PagingData
is not run on the backgroud thread in the Paging 3 library compared to PagedList
in Paging 2's library.
Expect (Based on the Paging Codelab sample)
- GithubPagingSource
override suspend fun load(...)
to run on an IO thread. - SearchRepositoriesActivity
viewModel.searchRepo(query).collectLatest { ... }
to run on the main thread.
Observe
- Both GithubPagingSource
override suspend fun load(...)
and SearchRepositoriesActivityviewModel.searchRepo(query).collectLatest { ... }
run on the main thread.
Threading is handled on the background by PagedList
with toLiveData
according to the documentation.
Paging 3If you use LivePagedListBuilder to get a LiveData, it will initialize PagedLists on a background thread for you.
The Paging 3 documentation does not mention how threading is managed. However, from the logs, PagingSource
appears to be running the network request on a main thread and returning the PagingData
on a main thread.
I've recreated the Codelab pattern in the CryptoTweets sample app app-simple module.
FeedPagingSource.kt
...ANSWER
Answered 2020-Sep-21 at 04:26When implementing PagingData
and PagingSource
with Kotlin Coroutines and making a Retrofit network request, as in the sample code above, Retrofit handles the background threading by default and returns on the main thread.
See StackOverflow: Does Retrofit make network calls on main thread?
RxJavaWhen using RxJava with Retrofit as the network source, the threading needs to be explicitly specified as shown in the Android documentation sample.
See Android documentation: Page from network and database > Implement a RemoteMediator
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install CryptoTweets
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page