Closed msfjarvis closed 2 years ago
@kuuuurt would you be able to take a look at this anytime soon?
Thansk for this @msfjarvis. I'm quite confused though. Isn't paging an Android dependency?
Thansk for this @msfjarvis. I'm quite confused though. Isn't paging an Android dependency?
It's not! paging-common
is actually built as a ~pura Java~ JVM library. See the difference in applied plugins for paging-common versus paging-runtime.
@kuuuurt is there anything you'd like for me to change in this PR for it to be ready?
Sorry @msfjarvis. I haven't found much time to work on personal projects. Thanks for letting me know that these are JVM libraries. Since these are not Android specific, can we just do a jvm()
instead of targeting both then merging in a jvmAndAndroidMain
?
@kuuuurt I've dropped the Android target, and renamed the source set to jvmMain
. Additionally I've also tested that I'm able to add it as a dependency in my Android sources.
Thanks @msfjarvis. This would be included in the next release 0.4.5
@msfjarvis 0.4.5 should be released
@msfjarvis 0.4.5 should be released
I saw, thanks a lot!
Thanks for your work! Could we also include your extensions like this one? I feels like it's a really good starting point for newcomer to find those functions + a minimal documentation on Desktop(Jvm). I can open another ticket and maybe even try to contribute if you're ok.
@Composable
fun <T : Any> Flow<PagingData<T>>.collectAsLazyPagingItems(): LazyPagingItems<T> {
val lazyPagingItems = remember(this) { LazyPagingItems(this) }
LaunchedEffect(lazyPagingItems) { lazyPagingItems.collectPagingData() }
LaunchedEffect(lazyPagingItems) { lazyPagingItems.collectLoadState() }
return lazyPagingItems
}
Thanks for your work! Could we also include your extensions like this one? I feels like it's a really good starting point for newcomer to find those functions + a minimal documentation on Desktop(Jvm). I can open another ticket and maybe even try to contribute if you're ok.
@Composable fun <T : Any> Flow<PagingData<T>>.collectAsLazyPagingItems(): LazyPagingItems<T> { val lazyPagingItems = remember(this) { LazyPagingItems(this) } LaunchedEffect(lazyPagingItems) { lazyPagingItems.collectPagingData() } LaunchedEffect(lazyPagingItems) { lazyPagingItems.collectLoadState() } return lazyPagingItems }
Unfortunately LazyPagingItems
belongs to the androidx.paging:paging-compose
library, which is published as an Android library rather than a JVM one. This prevents extensions like that to be compiled for desktop. For my own needs I ended up copying the class and removing its use of Android classes by hand, and I suspect that will have to be the case for everyone until proper Paging support is available for compose-desktop.
Thanks for the tip, will do the same!
The AndroidX Paging APIs currently used in the Android source set are not Android specific and can be used on desktop directly. To facilitate this with minimal code duplication, I have created a new
jvmAndAndroidMain
directory to share code between JVM and Android targets and moved all current Android code to it.I have tested this in a Compose for Desktop project, commits for which can be found here if needed.
This PR also includes a fix to allow syncing and publishing the project when
sonatype.properties
does not exist.Fixes #10