We have coded an Android/Kotlin application that can display and transmit multiple independently adjustable values on one Android screen. This is done by calling one function for each independently adjustable value which both uses "remember" and "mutableIntStateOf".
Because everything is in one function the coding pattern appears unstructured. We would like to correct this by splitting the current coding pattern into different functions. One for setting the value and another for sending the value to an externally connected device.
However, we have found it difficult to send the set value. Specifically, we have found it difficult to make the newest value in the setting function appear in the sending function.
We are considering using emit in the setting function to update a 3rd function which collects the newest values. Further, we are considering the sending function to stop any sending. But rather emit which value to send to this 3rd function which will then send the data to the externally connected device.
It is this last step we are currently working on. We have been unsuccessful so far. And the code is looking overly complex. So, at this point, I am asking this question to determine if our approach is reasonable. Or if Kotlin offers other more succinct ways to reach our goals.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744310210a4567910.html
评论列表(0条)