icerockdev / moko-mvvm

Model-View-ViewModel architecture components for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
1.02k stars 95 forks source link

Prevent memory churn described in #208 #209

Closed darronschall closed 1 year ago

darronschall commented 1 year ago

Fixes #208

Accessing stateFlow.value is not guaranteed to always return the same instance even when the underlying value is unchanged. This stateFlow behavior was incorrectly causing infinite objectWillChange events due to the equality test always reporting false even when the new value was, in fact, equal to the previous.

The fix is to go through isEqual(to:) to compare the value contents to determine equality before firing off an objectWillChange event.

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Alex009 commented 1 year ago

@kramlex check this please

kramlex commented 1 year ago

@Alex009 check this pr please

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication