diff options
author | Allan Wang <me@allanwang.ca> | 2021-11-23 18:29:05 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 18:29:05 -0800 |
commit | 120ad1520db9184ebfa00885066e06a9f976e5f6 (patch) | |
tree | 50835fa79cf15ff348be386c46cea0a05552ba74 /app/src/main/kotlin/com/pitchedapps/frost/contracts | |
parent | e246b35323e27dd18fa48910e5ca95669b53f8b0 (diff) | |
parent | db646e23ce0047461e68be1af7021ce6171ac850 (diff) | |
download | frost-120ad1520db9184ebfa00885066e06a9f976e5f6.tar.gz frost-120ad1520db9184ebfa00885066e06a9f976e5f6.tar.bz2 frost-120ad1520db9184ebfa00885066e06a9f976e5f6.zip |
Merge pull request #1857 from AllanWang/flows
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/contracts')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt | 13 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt | 24 |
2 files changed, 21 insertions, 16 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt index 756b1f3d..2b7f7b2c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt @@ -18,13 +18,16 @@ package com.pitchedapps.frost.contracts import com.mikepenz.iconics.typeface.IIcon import com.pitchedapps.frost.fragments.BaseFragment -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.channels.BroadcastChannel +import com.pitchedapps.frost.web.FrostEmitter +import kotlinx.coroutines.flow.SharedFlow -@UseExperimental(ExperimentalCoroutinesApi::class) interface MainActivityContract : MainFabContract { - val fragmentChannel: BroadcastChannel<Int> - val headerBadgeChannel: BroadcastChannel<String> + val fragmentFlow: SharedFlow<Int> + val fragmentEmit: FrostEmitter<Int> + + val headerFlow: SharedFlow<String> + val headerEmit: FrostEmitter<String> + fun setTitle(res: Int) fun setTitle(text: CharSequence) 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 b8d0d86f..7f91f901 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt @@ -18,9 +18,9 @@ package com.pitchedapps.frost.contracts import android.view.View import com.pitchedapps.frost.facebook.FbItem +import com.pitchedapps.frost.web.FrostEmitter import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.channels.BroadcastChannel +import kotlinx.coroutines.flow.SharedFlow /** * Created by Allan Wang on 20/12/17. @@ -46,7 +46,6 @@ interface FrostContentContainer : CoroutineScope { * Contract for components shared among * all content providers */ -@UseExperimental(ExperimentalCoroutinesApi::class) interface FrostContentParent : DynamicUiContract { val scope: CoroutineScope @@ -56,18 +55,23 @@ interface FrostContentParent : DynamicUiContract { /** * Observable to get data on whether view is refreshing or not */ - val refreshChannel: BroadcastChannel<Boolean> + val refreshFlow: SharedFlow<Boolean> + + val refreshEmit: FrostEmitter<Boolean> /** * Observable to get data on refresh progress, with range [0, 100] */ - val progressChannel: BroadcastChannel<Int> + val progressFlow: SharedFlow<Int> + + val progressEmit: FrostEmitter<Int> /** * Observable to get new title data (unique values only) */ - // todo note that this should be like a behavior subject vs publish subject - val titleChannel: BroadcastChannel<String> + val titleFlow: SharedFlow<String> + + val titleEmit: FrostEmitter<String> var baseUrl: String @@ -124,17 +128,15 @@ interface FrostContentCore : DynamicUiContract { * Reference to parent * Bound through calling [FrostContentParent.bind] */ - var parent: FrostContentParent + val parent: FrostContentParent /** * Initializes view through given [container] * * The content may be free to extract other data from * the container if necessary - * - * [parent] must be bounded before calling this! */ - fun bind(container: FrostContentContainer): View + fun bind(parent: FrostContentParent, container: FrostContentContainer): View /** * Call to reload wrapped data |