Skip to content

Replace mutable maps with StateFlow for reactive Compose updates#79

Merged
VictorB00 merged 1 commit into
mainfrom
refactor/reactive-state-with-stateflow
Jun 5, 2026
Merged

Replace mutable maps with StateFlow for reactive Compose updates#79
VictorB00 merged 1 commit into
mainfrom
refactor/reactive-state-with-stateflow

Conversation

@VictorB00

@VictorB00 VictorB00 commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replace ConcurrentHashMap in NubrickUser and FormRepository with MutableStateFlow, enabling Compose to reactively recompose when user properties or form values change via collectAsStateWithLifecycle
  • Split HTTP request handling into compileHttpRequest (pure) and sendCompiledHttpRequest (IO) with new CompiledHttpRequest/CompiledHttpHeader data classes, allowing proper remember keying and avoiding redundant network calls
  • Simplify rememberPageState and rememberNestedDataState by composing template variables directly instead of re-calling createVariableForTemplate
  • Switch dependency from lifecycle-runtime-ktx to lifecycle-runtime-compose and move it to the nubrick module

Fixes https://github.com/plaidev/nativebrik/issues/2035

Test plan

  • Verify pages load data correctly and display template variables
  • Verify form inputs update template variables reactively
  • Verify user property changes (e.g. setUserId, setProperty) reflect in the UI
  • Verify nested data states render correctly
  • Verify HTTP requests fire only when compiled request changes
  • Run existing unit tests

@VictorB00 VictorB00 merged commit 7be7298 into main Jun 5, 2026
1 check passed
@VictorB00 VictorB00 deleted the refactor/reactive-state-with-stateflow branch June 5, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant