When to use postvalue [duplicate]

According to the documentation:

Based on the documentation:


Sets the value. If there are active observers, the value will be dispatched to them. This method must be called from the main thread.


Posts a task to a main thread to set the given value. If you called this method multiple times before a main thread executed a posted task, only the last value would be dispatched.

So I would always use setValue when possible, in your case as you have noticed setValue is better because you can be sure it will always be on the Main Thread.

However postValue can also be called from the Main Thread, but will perform a tiny bit worse.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top