Fixed
Status Update
Comments
do...@traveloka.com <do...@traveloka.com> #2
+1, but Deferred does not solve the Observer problem that Rx and LiveData do, so I guess Google should implement Channels instead of LiveData which is actually a Kotlin Coroutine counterpart. Looking forward to this as I've decided not to use RxJava in most of future projects due to Kotlin Coroutines..
pa...@gmail.com <pa...@gmail.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit e78cceffeac28f0028342990c1391c640edf453c
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed Nov 28 12:40:24 2018
Room Support for Coroutines
This change allows users to define suspend functions in DAOs with
@Query, @Insert, @Update and @Delete. The new artifact room-coroutine
defines a helper classes for supporting the feature.
Bug: 69474692
Test: ./gradlew room:integration-tests:kotlintestapp:cC
Change-Id: Id73a6b845df3f21f99d14cb6980130dcf3885c81
M buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
A room/compiler/src/main/kotlin/androidx/room/ext/KotlinMetadataElement.kt
D room/compiler/src/main/kotlin/androidx/room/ext/KotlinMetadataProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/ext/element_ext.kt
M room/compiler/src/main/kotlin/androidx/room/ext/javapoet_ext.kt
M room/compiler/src/main/kotlin/androidx/room/processor/DeletionMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/InsertionMethodProcessor.kt
A room/compiler/src/main/kotlin/androidx/room/processor/MethodProcessorDelegate.kt
M room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ShortcutMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt
A room/compiler/src/main/kotlin/androidx/room/solver/query/result/CoroutineResultBinder.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
A room/compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineDeleteOrUpdateMethodBinder.kt
A room/compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineInsertMethodBinder.kt
M room/compiler/src/main/kotlin/androidx/room/solver/shortcut/result/DeleteOrUpdateMethodAdapter.kt
M room/compiler/src/main/kotlin/androidx/room/solver/shortcut/result/InsertMethodAdapter.kt
M room/compiler/src/main/kotlin/androidx/room/vo/RelationCollector.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
A room/coroutines/build.gradle
A room/coroutines/src/main/AndroidManifest.xml
A room/coroutines/src/main/java/androidx/room/CoroutinesRoom.kt
M room/integration-tests/kotlintestapp/build.gradle
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/dao/BooksDao.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/BooksDaoTest.kt
A room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendRoomDispatcherTest.kt
M settings.gradle
https://android-review.googlesource.com/833705
https://goto.google.com/android-sha1/e78cceffeac28f0028342990c1391c640edf453c
Branch: androidx-master-dev
commit e78cceffeac28f0028342990c1391c640edf453c
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed Nov 28 12:40:24 2018
Room Support for Coroutines
This change allows users to define suspend functions in DAOs with
@Query, @Insert, @Update and @Delete. The new artifact room-coroutine
defines a helper classes for supporting the feature.
Bug: 69474692
Test: ./gradlew room:integration-tests:kotlintestapp:cC
Change-Id: Id73a6b845df3f21f99d14cb6980130dcf3885c81
M buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
A room/compiler/src/main/kotlin/androidx/room/ext/KotlinMetadataElement.kt
D room/compiler/src/main/kotlin/androidx/room/ext/KotlinMetadataProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/ext/element_ext.kt
M room/compiler/src/main/kotlin/androidx/room/ext/javapoet_ext.kt
M room/compiler/src/main/kotlin/androidx/room/processor/DeletionMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/InsertionMethodProcessor.kt
A room/compiler/src/main/kotlin/androidx/room/processor/MethodProcessorDelegate.kt
M room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ShortcutMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt
A room/compiler/src/main/kotlin/androidx/room/solver/query/result/CoroutineResultBinder.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
A room/compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineDeleteOrUpdateMethodBinder.kt
A room/compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineInsertMethodBinder.kt
M room/compiler/src/main/kotlin/androidx/room/solver/shortcut/result/DeleteOrUpdateMethodAdapter.kt
M room/compiler/src/main/kotlin/androidx/room/solver/shortcut/result/InsertMethodAdapter.kt
M room/compiler/src/main/kotlin/androidx/room/vo/RelationCollector.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
A room/coroutines/build.gradle
A room/coroutines/src/main/AndroidManifest.xml
A room/coroutines/src/main/java/androidx/room/CoroutinesRoom.kt
M room/integration-tests/kotlintestapp/build.gradle
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/dao/BooksDao.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/BooksDaoTest.kt
A room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendRoomDispatcherTest.kt
M settings.gradle
pa...@gmail.com <pa...@gmail.com> #4
So do you support any Coroutine "observables" like channels? Or these are just one-off suspending calls?
ga...@google.com <ga...@google.com> #5
For now we'll be just supporting one-off suspend functions in Room 2.1.0-alpha03. Coroutines stream functionality with channels is still a work in progress.
pa...@google.com <pa...@google.com> #6
Relating to the original request, how about allowing a return type of Deferred<LiveData<T>> which suspends until LiveData<T>'s value has been set the first time?
ap...@google.com <ap...@google.com> #7
I just tested out Room 2.1.0-alpha03 and added suspend to all of my functions.... there appears to be an issue with functions that use @Query() and UPDATE and DELETE queries. Examples:
Code Example 1:
@Query("DELETE FROM individual")
suspend fun deleteAll()
Error:
Deletion methods must either return void or return int (the number of deleted rows).
Code Example 2:
@Query("UPDATE individual SET firstName = :firstName WHERE id = :id")
suspend fun updateFirstName(id: Long, firstName: String)
Error:
Not sure how to convert a Cursor to this method's return type (kotlin.Unit).
Code Example 1:
@Query("DELETE FROM individual")
suspend fun deleteAll()
Error:
Deletion methods must either return void or return int (the number of deleted rows).
Code Example 2:
@Query("UPDATE individual SET firstName = :firstName WHERE id = :id")
suspend fun updateFirstName(id: Long, firstName: String)
Error:
Not sure how to convert a Cursor to this method's return type (kotlin.Unit).
pa...@google.com <pa...@google.com> #8
Async return types with @Query that perform UPDATE, DELETE or INSERT are not yet supported. This also applies to coroutines. We are actively working on adding this for the next alpha of 2.1.0. Subscribe to the bug for updates: https://issuetracker.google.com/issues/120227284
pa...@gmail.com <pa...@gmail.com> #9
Hello.
Any updates on returning Channel<T> from DAO?
Will contributions be accepted for that feature?
Any updates on returning Channel<T> from DAO?
Will contributions be accepted for that feature?
hu...@google.com <hu...@google.com> #10
Channels are experimental right now so we probably want to wait until it is stable.
Description
Java version "1.8.0_121"
Jetifier version: 1.0.0-beta04
Let there be a Library Foo with the following 'proguard-rules.txt' file:
# DBFlow
-keep class * extends com.raizlabs.android.dbflow.config.DatabaseHolder { *; }
-dontwarn com.raizlabs.android.dbflow.**
# Note: the configuration keeps the entry point 'com.raizlabs.android.dbflow.config.FlowManager$GlobalDatabaseHolder { FlowManager$GlobalDatabaseHolder(com.raizlabs.android.dbflow.config.FlowManager$1); }', but not the descriptor class 'com.raizlabs.android.dbflow.config.FlowManager$1'
-keep class com.raizlabs.android.dbflow.config.FlowManager$*
When trying to jetify this library:
./jetifier-standalone -i /Users/someuser/Downloads/foo/foo.aar -o newfoo.aar
The Jetifier fails with the following output:
Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repetition near index 147
com/raizlabs/android/dbflow/.*
# Note: the configuration keeps the entry point 'com/raizlabs/android/dbflow/config/FlowManager$GlobalDatabaseHolder { FlowManager$GlobalDatabaseHolder(com/raizlabs/android/dbflow/config/FlowManager$1); }'
^
at java.util.regex.Pattern.error(Pattern.java:1955)
at java.util.regex.Pattern.closure(Pattern.java:3157)
at java.util.regex.Pattern.sequence(Pattern.java:2134)
at java.util.regex.Pattern.expr(Pattern.java:1996)
at java.util.regex.Pattern.compile(Pattern.java:1696)
at java.util.regex.Pattern.<init>(Pattern.java:1351)
at java.util.regex.Pattern.compile(Pattern.java:1028)
at com.android.tools.build.jetifier.core.type.TypesMap.matchOldProguardForNewTypes(TypesMap.kt:112)
[...]
If i remove the notes, the new 'proguard-rules.txt' looks like this:
# DBFlow
-keep class * extends com.raizlabs.android.dbflow.config.DatabaseHolder { *; }
-dontwarn com.raizlabs.android.dbflow.**
-keep class com.raizlabs.android.dbflow.config.FlowManager$*
And this runs through the jetifier just fine. Please provide a fix for this issue, since i have to patch my dependencies currently in order to make AndroidX work for me.