aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-12-27 02:15:10 -0500
committerAllan Wang <me@allanwang.ca>2018-12-27 02:15:10 -0500
commite6dcbd7b32dc49b11184b6beca598819c3f071fd (patch)
treea02691a1eaf1b1506930c7e50c5f43f6f0fc953a /app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt
parent7d85262ada198501d2d5844e1196c9b45f4a38f5 (diff)
downloadfrost-e6dcbd7b32dc49b11184b6beca598819c3f071fd.tar.gz
frost-e6dcbd7b32dc49b11184b6beca598819c3f071fd.tar.bz2
frost-e6dcbd7b32dc49b11184b6beca598819c3f071fd.zip
Begin replacing observables with channels
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt18
1 files changed, 17 insertions, 1 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt
index 50c2fe77..a2c2b05a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt
@@ -20,6 +20,10 @@ import android.view.View
import com.pitchedapps.frost.facebook.FbItem
import io.reactivex.subjects.BehaviorSubject
import io.reactivex.subjects.PublishSubject
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.channels.BroadcastChannel
+import kotlinx.coroutines.channels.Channel
/**
* Created by Allan Wang on 20/12/17.
@@ -29,7 +33,7 @@ import io.reactivex.subjects.PublishSubject
* Contract for the underlying parent,
* binds to activities & fragments
*/
-interface FrostContentContainer {
+interface FrostContentContainer : CoroutineScope {
val baseUrl: String
@@ -45,8 +49,11 @@ interface FrostContentContainer {
* Contract for components shared among
* all content providers
*/
+@UseExperimental(ExperimentalCoroutinesApi::class)
interface FrostContentParent : DynamicUiContract {
+ val scope: CoroutineScope
+
val core: FrostContentCore
/**
@@ -54,16 +61,22 @@ interface FrostContentParent : DynamicUiContract {
*/
val refreshObservable: PublishSubject<Boolean>
+ val refreshChannel: BroadcastChannel<Boolean>
+
/**
* Observable to get data on refresh progress, with range [0, 100]
*/
val progressObservable: PublishSubject<Int>
+ val progressChannel: BroadcastChannel<Int>
+
/**
* Observable to get new title data (unique values only)
*/
val titleObservable: BehaviorSubject<String>
+ val titleChannel: BroadcastChannel<String>
+
var baseUrl: String
var baseEnum: FbItem?
@@ -106,6 +119,9 @@ interface FrostContentParent : DynamicUiContract {
*/
interface FrostContentCore : DynamicUiContract {
+ val scope: CoroutineScope
+ get() = parent.scope
+
/**
* Reference to parent
* Bound through calling [FrostContentParent.bind]