updateSync
Updates this state value and enqueues a new layout calculation reflecting it to execute on the current thread. If called on the main thread, this means that the UI will be updated for the current frame.
Note: If updateSync is used on the main thread, it can easily cause dropped frames and degrade user experience. Therefore it should only be used in exceptional circumstances or when it's known to be executed off the main thread.
Uses newValueFunction to update this state value using the previous state value, and enqueues a new layout calculation reflecting it to execute on the current thread.
newValueFunction receives the current state value and can use it to compute the update: this is useful when there could be other enqueued updates that may not have been applied yet.
For example, if your state update should increment a counter, using the function version of update with count -> count + 1
will allow you to account for updates that are in flight but not yet applied (e.g. if the user has tapped a button triggering the update multiple times in succession).
Note: If updateSync is used on the main thread, it can easily cause dropped frames and degrade user experience. Therefore it should only be used in exceptional circumstances or when it's known to be executed off the main thread.