Skip to content

Make DashboardScope accept Flow instead of StateFlow#507

Merged
rteyssandier merged 2 commits intoopenflocon:mainfrom
snappdevelopment:dashboardscope-accepts-flows
Mar 7, 2026
Merged

Make DashboardScope accept Flow instead of StateFlow#507
rteyssandier merged 2 commits intoopenflocon:mainfrom
snappdevelopment:dashboardscope-accepts-flows

Conversation

@snappdevelopment
Copy link
Copy Markdown
Contributor

The section and form functions in the DashboardScope currently expect a StateFlow, but internally it is just used like a regular Flow. Sometimes the user has regular flows and it is a bit inconvenient to convert those to StateFlows, instead of just passing them directly to section.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the DashboardScope interface by broadening the type of reactive data streams it accepts. Previously, the section and form functions strictly required StateFlow, which could lead to unnecessary conversions for users working with standard Flow instances. By updating these functions to accept the more general Flow type, the API becomes more user-friendly and reduces boilerplate, streamlining the development experience for dashboard components.

Highlights

  • API Flexibility: The section and form functions in DashboardScope now accept Flow<T> instead of StateFlow<T>, allowing for greater flexibility when providing data.
  • Reduced Boilerplate: This change eliminates the need for users to convert regular Flow instances to StateFlow when interacting with these dashboard functions.
Changelog
  • FloconAndroid/flocon-base/src/commonMain/kotlin/io/github/openflocon/flocon/plugins/dashboard/model/DashboardScope.kt
    • Updated the section function signature to accept Flow<T> instead of StateFlow<T>.
    • Updated the form function signature to accept Flow<T> instead of StateFlow<T>.
  • FloconAndroid/flocon/src/commonMain/kotlin/io/github/openflocon/flocon/plugins/dashboard/FloconDashboardDSL.kt
    • Modified the section function implementation to use Flow<T> as the parameter type.
    • Modified the form function implementation to use Flow<T> as the parameter type.
    • Updated KDoc comments for section and form to reflect the change from StateFlow to Flow.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the DashboardScope to accept Flow instead of StateFlow for section and form functions, making the API more flexible. The implementation is updated accordingly. I've included comments to address some now-unused imports for code cleanup.


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.

* @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.

@rteyssandier rteyssandier added the enhancement New feature or request label Mar 6, 2026
@rteyssandier
Copy link
Copy Markdown
Contributor

Fix gemini import discussion, and we should be good.

@snappdevelopment
Copy link
Copy Markdown
Contributor Author

@rteyssandier Thanks, I fixed it

@rteyssandier rteyssandier merged commit 7a0c65f into openflocon:main Mar 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants