@@ -38,19 +38,17 @@ public enum class SharingCommand {
38
38
/* *
39
39
* A strategy for starting and stopping the sharing coroutine in [shareIn] and [stateIn] operators.
40
40
*
41
- * This interface provides a set of built-in strategies: [Eagerly], [Lazily], [WhileSubscribed], and
41
+ * This functional interface provides a set of built-in strategies: [Eagerly], [Lazily], [WhileSubscribed], and
42
42
* supports custom strategies by implementing this interface's [command] function.
43
43
*
44
44
* For example, it is possible to define a custom strategy that starts the upstream only when the number
45
45
* of subscribers exceeds the given `threshold` and make it an extension on [SharingStarted.Companion] so
46
46
* that it looks like a built-in strategy on the use-site:
47
47
*
48
48
* ```
49
- * fun SharingStarted.Companion.WhileSubscribedAtLeast(threshold: Int): SharingStarted =
50
- * object : SharingStarted {
51
- * override fun command(subscriptionCount: StateFlow<Int>): Flow<SharingCommand> =
52
- * subscriptionCount
53
- * .map { if (it >= threshold) SharingCommand.START else SharingCommand.STOP }
49
+ * fun SharingStarted.Companion.WhileSubscribedAtLeast(threshold: Int) =
50
+ * SharingStarted { subscriptionCount: StateFlow<Int> ->
51
+ * subscriptionCount.map { if (it >= threshold) SharingCommand.START else SharingCommand.STOP }
54
52
* }
55
53
* ```
56
54
*
@@ -74,7 +72,7 @@ public enum class SharingCommand {
74
72
* The completion of the `command` flow normally has no effect (the upstream flow keeps running if it was running).
75
73
* The failure of the `command` flow cancels the sharing coroutine and the upstream flow.
76
74
*/
77
- public interface SharingStarted {
75
+ public fun interface SharingStarted {
78
76
public companion object {
79
77
/* *
80
78
* Sharing is started immediately and never stops.
0 commit comments