正在显示
5 个修改的文件
包含
26 行增加
和
3 行删除
| @@ -65,17 +65,21 @@ constructor( | @@ -65,17 +65,21 @@ constructor( | ||
| 65 | @Deprecated("Use events instead.") | 65 | @Deprecated("Use events instead.") |
| 66 | var listener: RoomListener? = null | 66 | var listener: RoomListener? = null |
| 67 | 67 | ||
| 68 | + @FlowObservable | ||
| 68 | @get:FlowObservable | 69 | @get:FlowObservable |
| 69 | var sid: Sid? by flowDelegate(null) | 70 | var sid: Sid? by flowDelegate(null) |
| 70 | 71 | ||
| 72 | + @FlowObservable | ||
| 71 | @get:FlowObservable | 73 | @get:FlowObservable |
| 72 | var name: String? by flowDelegate(null) | 74 | var name: String? by flowDelegate(null) |
| 73 | private set | 75 | private set |
| 74 | 76 | ||
| 77 | + @FlowObservable | ||
| 75 | @get:FlowObservable | 78 | @get:FlowObservable |
| 76 | var state: State by flowDelegate(State.DISCONNECTED) | 79 | var state: State by flowDelegate(State.DISCONNECTED) |
| 77 | private set | 80 | private set |
| 78 | 81 | ||
| 82 | + @FlowObservable | ||
| 79 | @get:FlowObservable | 83 | @get:FlowObservable |
| 80 | var metadata: String? by flowDelegate(null) | 84 | var metadata: String? by flowDelegate(null) |
| 81 | private set | 85 | private set |
| @@ -129,12 +133,14 @@ constructor( | @@ -129,12 +133,14 @@ constructor( | ||
| 129 | 133 | ||
| 130 | private var mutableRemoteParticipants by flowDelegate(emptyMap<String, RemoteParticipant>()) | 134 | private var mutableRemoteParticipants by flowDelegate(emptyMap<String, RemoteParticipant>()) |
| 131 | 135 | ||
| 136 | + @FlowObservable | ||
| 132 | @get:FlowObservable | 137 | @get:FlowObservable |
| 133 | val remoteParticipants: Map<String, RemoteParticipant> | 138 | val remoteParticipants: Map<String, RemoteParticipant> |
| 134 | get() = mutableRemoteParticipants | 139 | get() = mutableRemoteParticipants |
| 135 | 140 | ||
| 136 | private var mutableActiveSpeakers by flowDelegate(emptyList<Participant>()) | 141 | private var mutableActiveSpeakers by flowDelegate(emptyList<Participant>()) |
| 137 | 142 | ||
| 143 | + @FlowObservable | ||
| 138 | @get:FlowObservable | 144 | @get:FlowObservable |
| 139 | val activeSpeakers: List<Participant> | 145 | val activeSpeakers: List<Participant> |
| 140 | get() = mutableActiveSpeakers | 146 | get() = mutableActiveSpeakers |
| @@ -34,6 +34,7 @@ open class Participant( | @@ -34,6 +34,7 @@ open class Participant( | ||
| 34 | /** | 34 | /** |
| 35 | * Changes can be observed by using [io.livekit.android.util.flow] | 35 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 36 | */ | 36 | */ |
| 37 | + @FlowObservable | ||
| 37 | @get:FlowObservable | 38 | @get:FlowObservable |
| 38 | var participantInfo: LivekitModels.ParticipantInfo? by flowDelegate(null) | 39 | var participantInfo: LivekitModels.ParticipantInfo? by flowDelegate(null) |
| 39 | private set | 40 | private set |
| @@ -41,6 +42,7 @@ open class Participant( | @@ -41,6 +42,7 @@ open class Participant( | ||
| 41 | /** | 42 | /** |
| 42 | * Changes can be observed by using [io.livekit.android.util.flow] | 43 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 43 | */ | 44 | */ |
| 45 | + @FlowObservable | ||
| 44 | @get:FlowObservable | 46 | @get:FlowObservable |
| 45 | var identity: String? by flowDelegate(identity) | 47 | var identity: String? by flowDelegate(identity) |
| 46 | internal set | 48 | internal set |
| @@ -48,6 +50,7 @@ open class Participant( | @@ -48,6 +50,7 @@ open class Participant( | ||
| 48 | /** | 50 | /** |
| 49 | * Changes can be observed by using [io.livekit.android.util.flow] | 51 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 50 | */ | 52 | */ |
| 53 | + @FlowObservable | ||
| 51 | @get:FlowObservable | 54 | @get:FlowObservable |
| 52 | var audioLevel: Float by flowDelegate(0f) | 55 | var audioLevel: Float by flowDelegate(0f) |
| 53 | internal set | 56 | internal set |
| @@ -55,6 +58,7 @@ open class Participant( | @@ -55,6 +58,7 @@ open class Participant( | ||
| 55 | /** | 58 | /** |
| 56 | * Changes can be observed by using [io.livekit.android.util.flow] | 59 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 57 | */ | 60 | */ |
| 61 | + @FlowObservable | ||
| 58 | @get:FlowObservable | 62 | @get:FlowObservable |
| 59 | var isSpeaking: Boolean by flowDelegate(false) { newValue, oldValue -> | 63 | var isSpeaking: Boolean by flowDelegate(false) { newValue, oldValue -> |
| 60 | if (newValue != oldValue) { | 64 | if (newValue != oldValue) { |
| @@ -64,13 +68,15 @@ open class Participant( | @@ -64,13 +68,15 @@ open class Participant( | ||
| 64 | } | 68 | } |
| 65 | } | 69 | } |
| 66 | internal set | 70 | internal set |
| 67 | - | 71 | + |
| 72 | + @FlowObservable | ||
| 68 | @get:FlowObservable | 73 | @get:FlowObservable |
| 69 | var name by flowDelegate<String?>(null) | 74 | var name by flowDelegate<String?>(null) |
| 70 | 75 | ||
| 71 | /** | 76 | /** |
| 72 | * Changes can be observed by using [io.livekit.android.util.flow] | 77 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 73 | */ | 78 | */ |
| 79 | + @FlowObservable | ||
| 74 | @get:FlowObservable | 80 | @get:FlowObservable |
| 75 | var metadata: String? by flowDelegate(null) { newMetadata, oldMetadata -> | 81 | var metadata: String? by flowDelegate(null) { newMetadata, oldMetadata -> |
| 76 | if (newMetadata != oldMetadata) { | 82 | if (newMetadata != oldMetadata) { |
| @@ -84,6 +90,7 @@ open class Participant( | @@ -84,6 +90,7 @@ open class Participant( | ||
| 84 | /** | 90 | /** |
| 85 | * Changes can be observed by using [io.livekit.android.util.flow] | 91 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 86 | */ | 92 | */ |
| 93 | + @FlowObservable | ||
| 87 | @get:FlowObservable | 94 | @get:FlowObservable |
| 88 | var connectionQuality by flowDelegate(ConnectionQuality.UNKNOWN) | 95 | var connectionQuality by flowDelegate(ConnectionQuality.UNKNOWN) |
| 89 | internal set | 96 | internal set |
| @@ -106,6 +113,7 @@ open class Participant( | @@ -106,6 +113,7 @@ open class Participant( | ||
| 106 | /** | 113 | /** |
| 107 | * Changes can be observed by using [io.livekit.android.util.flow] | 114 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 108 | */ | 115 | */ |
| 116 | + @FlowObservable | ||
| 109 | @get:FlowObservable | 117 | @get:FlowObservable |
| 110 | var tracks by flowDelegate(emptyMap<String, TrackPublication>()) | 118 | var tracks by flowDelegate(emptyMap<String, TrackPublication>()) |
| 111 | protected set | 119 | protected set |
| @@ -113,6 +121,7 @@ open class Participant( | @@ -113,6 +121,7 @@ open class Participant( | ||
| 113 | /** | 121 | /** |
| 114 | * Changes can be observed by using [io.livekit.android.util.flow] | 122 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 115 | */ | 123 | */ |
| 124 | + @FlowObservable | ||
| 116 | @get:FlowObservable | 125 | @get:FlowObservable |
| 117 | val audioTracks by flowDelegate( | 126 | val audioTracks by flowDelegate( |
| 118 | stateFlow = ::tracks.flow | 127 | stateFlow = ::tracks.flow |
| @@ -123,6 +132,7 @@ open class Participant( | @@ -123,6 +132,7 @@ open class Participant( | ||
| 123 | /** | 132 | /** |
| 124 | * Changes can be observed by using [io.livekit.android.util.flow] | 133 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 125 | */ | 134 | */ |
| 135 | + @FlowObservable | ||
| 126 | @get:FlowObservable | 136 | @get:FlowObservable |
| 127 | val videoTracks by flowDelegate( | 137 | val videoTracks by flowDelegate( |
| 128 | stateFlow = ::tracks.flow | 138 | stateFlow = ::tracks.flow |
| @@ -12,6 +12,7 @@ open class TrackPublication( | @@ -12,6 +12,7 @@ open class TrackPublication( | ||
| 12 | participant: Participant | 12 | participant: Participant |
| 13 | ) { | 13 | ) { |
| 14 | 14 | ||
| 15 | + @FlowObservable | ||
| 15 | @get:FlowObservable | 16 | @get:FlowObservable |
| 16 | open var track: Track? by flowDelegate(track) | 17 | open var track: Track? by flowDelegate(track) |
| 17 | internal set | 18 | internal set |
| @@ -22,6 +23,7 @@ open class TrackPublication( | @@ -22,6 +23,7 @@ open class TrackPublication( | ||
| 22 | var kind: Track.Kind | 23 | var kind: Track.Kind |
| 23 | private set | 24 | private set |
| 24 | 25 | ||
| 26 | + @FlowObservable | ||
| 25 | @get:FlowObservable | 27 | @get:FlowObservable |
| 26 | open var muted: Boolean by flowDelegate(false) | 28 | open var muted: Boolean by flowDelegate(false) |
| 27 | internal set | 29 | internal set |
| @@ -65,7 +65,7 @@ val <T> KProperty0<T>.flow: StateFlow<T> | @@ -65,7 +65,7 @@ val <T> KProperty0<T>.flow: StateFlow<T> | ||
| 65 | /** | 65 | /** |
| 66 | * Indicates that the target property changes can be observed with [flow]. | 66 | * Indicates that the target property changes can be observed with [flow]. |
| 67 | */ | 67 | */ |
| 68 | -@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY_GETTER) | 68 | +@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER) |
| 69 | @Retention(AnnotationRetention.BINARY) | 69 | @Retention(AnnotationRetention.BINARY) |
| 70 | @MustBeDocumented | 70 | @MustBeDocumented |
| 71 | annotation class FlowObservable | 71 | annotation class FlowObservable |
| @@ -22,6 +22,7 @@ class FlowDelegateUsageDetectorTest { | @@ -22,6 +22,7 @@ class FlowDelegateUsageDetectorTest { | ||
| 22 | import io.livekit.android.util.flow | 22 | import io.livekit.android.util.flow |
| 23 | import io.livekit.android.util.flowDelegate | 23 | import io.livekit.android.util.flowDelegate |
| 24 | class Example { | 24 | class Example { |
| 25 | + @FlowObservable | ||
| 25 | @get:FlowObservable | 26 | @get:FlowObservable |
| 26 | val value: Int by flowDelegate(0) | 27 | val value: Int by flowDelegate(0) |
| 27 | fun foo() { | 28 | fun foo() { |
| @@ -50,6 +51,7 @@ class FlowDelegateUsageDetectorTest { | @@ -50,6 +51,7 @@ class FlowDelegateUsageDetectorTest { | ||
| 50 | import io.livekit.android.util.flow | 51 | import io.livekit.android.util.flow |
| 51 | import io.livekit.android.util.flowDelegate | 52 | import io.livekit.android.util.flowDelegate |
| 52 | class Example { | 53 | class Example { |
| 54 | + @FlowObservable | ||
| 53 | @get:FlowObservable | 55 | @get:FlowObservable |
| 54 | val value: Int by flowDelegate(0) | 56 | val value: Int by flowDelegate(0) |
| 55 | fun foo() { | 57 | fun foo() { |
| @@ -78,6 +80,7 @@ class FlowDelegateUsageDetectorTest { | @@ -78,6 +80,7 @@ class FlowDelegateUsageDetectorTest { | ||
| 78 | import io.livekit.android.util.flow | 80 | import io.livekit.android.util.flow |
| 79 | import io.livekit.android.util.flowDelegate | 81 | import io.livekit.android.util.flowDelegate |
| 80 | class FlowContainer { | 82 | class FlowContainer { |
| 83 | + @FlowObservable | ||
| 81 | @get:FlowObservable | 84 | @get:FlowObservable |
| 82 | val value: Int by flowDelegate(0) | 85 | val value: Int by flowDelegate(0) |
| 83 | } | 86 | } |
| @@ -109,6 +112,7 @@ class FlowDelegateUsageDetectorTest { | @@ -109,6 +112,7 @@ class FlowDelegateUsageDetectorTest { | ||
| 109 | import io.livekit.android.util.flow | 112 | import io.livekit.android.util.flow |
| 110 | import io.livekit.android.util.flowDelegate | 113 | import io.livekit.android.util.flowDelegate |
| 111 | class FlowContainer { | 114 | class FlowContainer { |
| 115 | + @FlowObservable | ||
| 112 | @get:FlowObservable | 116 | @get:FlowObservable |
| 113 | val value: Int by flowDelegate(0) | 117 | val value: Int by flowDelegate(0) |
| 114 | } | 118 | } |
| @@ -141,6 +145,7 @@ class FlowDelegateUsageDetectorTest { | @@ -141,6 +145,7 @@ class FlowDelegateUsageDetectorTest { | ||
| 141 | import io.livekit.android.util.flowDelegate | 145 | import io.livekit.android.util.flowDelegate |
| 142 | class FlowContainer { | 146 | class FlowContainer { |
| 143 | var value: Int by flowDelegate(0) | 147 | var value: Int by flowDelegate(0) |
| 148 | + @FlowObservable | ||
| 144 | @get:FlowObservable | 149 | @get:FlowObservable |
| 145 | val otherValue: Int | 150 | val otherValue: Int |
| 146 | get() = value | 151 | get() = value |
| @@ -205,7 +210,7 @@ fun flowAccess(): TestFile { | @@ -205,7 +210,7 @@ fun flowAccess(): TestFile { | ||
| 205 | val <T> KProperty0<T>.flow: StateFlow<T> | 210 | val <T> KProperty0<T>.flow: StateFlow<T> |
| 206 | get() = delegate as StateFlow<T> | 211 | get() = delegate as StateFlow<T> |
| 207 | 212 | ||
| 208 | - @Target(AnnotationTarget.PROPERTY_GETTER) | 213 | + @Target(AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER) |
| 209 | @Retention(AnnotationRetention.SOURCE) | 214 | @Retention(AnnotationRetention.SOURCE) |
| 210 | @MustBeDocumented | 215 | @MustBeDocumented |
| 211 | annotation class FlowObservable | 216 | annotation class FlowObservable |
-
请 注册 或 登录 后发表评论