voize-gmbh / reakt-native-toolkit

Combine React Native with Kotlin Multiplatform (KMP)
Apache License 2.0
134 stars 5 forks source link

[question] Behavior of example function `TimeProvider.time()` #56

Closed rocketraman closed 7 months ago

rocketraman commented 7 months ago

The Example app has a function TimeProvider.time():

https://github.com/voize-gmbh/reakt-native-toolkit/blob/main/example/android/shared/src/commonMain/kotlin/com/myrnproject/shared/TimeProvider.kt#L18

When this is used in a React Native view, the time updates very quickly -- on the order of every 1 or 2 milliseconds. When timeAsState is used, the time updates every second as expected.

Is this just an example of using a Flow incorrectly i.e. without turning it into a StateFlow? Or is it an indication of a bug in the flow toReact code?

Legion2 commented 7 months ago

It demonstrates how the toolkit works and it reevaluates the flow many times, so one should be aware of this when using flows that are non deterministic

rocketraman commented 7 months ago

Thank you!