Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package io.github.openflocon.flocon.plugins.dashboard.model

import io.github.openflocon.flocon.plugins.dashboard.builder.FormBuilder
import io.github.openflocon.flocon.plugins.dashboard.builder.SectionBuilder
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.Flow

interface DashboardScope {
fun <T> section(name: String, flow: StateFlow<T>, content: SectionBuilder.(T) -> Unit)
fun <T> section(name: String, flow: Flow<T>, content: SectionBuilder.(T) -> Unit)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

With StateFlow being replaced by Flow throughout this interface, the import kotlinx.coroutines.flow.StateFlow on line 6 is now unused and can be removed.

fun section(name: String, content: SectionBuilder.() -> Unit)

fun <T> form(
name: String,
submitText: String = "Submit",
onSubmitted: (Map<String, String>) -> Unit,
flow: StateFlow<T>,
flow: Flow<T>,
content: FormBuilder.(T) -> Unit
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
Expand Down Expand Up @@ -57,10 +56,10 @@ internal class DashboardScopeImpl : DashboardScope {
* The section will be re-rendered whenever the [flow] emits a new value.
*
* @param name The name of the section.
* @param flow The [StateFlow] providing the data for the section.
* @param flow The [Flow] providing the data for the section.
* @param content The builder to construct the section content based on the data.
*/
override fun <T> section(name: String, flow: StateFlow<T>, content: SectionBuilder.(T) -> Unit) {
override fun <T> section(name: String, flow: Flow<T>, content: SectionBuilder.(T) -> Unit) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

With the changes in this file, StateFlow is no longer used. Please remove the unused import from line 13.

val sectionFlow = flow.map { item ->
SectionBuilder(name)
.apply { content(item) }
Expand Down Expand Up @@ -90,14 +89,14 @@ internal class DashboardScopeImpl : DashboardScope {
* @param name The name of the form.
* @param submitText The text to display on the submit button.
* @param onSubmitted The callback to be invoked when the form is submitted.
* @param flow The [StateFlow] providing the data for the form.
* @param flow The [Flow] providing the data for the form.
* @param content The builder to construct the form content based on the data.
*/
override fun <T> form(
name: String,
submitText: String,
onSubmitted: (Map<String, String>) -> Unit,
flow: StateFlow<T>,
flow: Flow<T>,
content: FormBuilder.(T) -> Unit
) {
val formFlow = flow.map { item ->
Expand Down