Michael Spitsin
1 min readSep 10, 2020

--

Hey, Haris. Good question!

This is the tricky part, since we run item property update in the main thread. When property is updated it dispatch the job inside `updateList` to main coroutine dispatcher which is attached to the main thread.

Since the main thread is only one, there will be only one action executed at time. When we dispatched the job to main coroutine context, this job will not be started since the main thread is still busy with updating fields inside `mapUser` method.

Only when this work will be done (and that means that both properties will be updated) the thread become free and main coroutine context will trigger the job, that was dispatched in the first `userItem` update but could, but could not be started, since thread was busy

That means that the `update()` method inside `updateList` will be called only after every item will be updated in the current frame :)

--

--

Michael Spitsin
Michael Spitsin

Written by Michael Spitsin

Love being creative to solve some problems with an simple and elegant ways

Responses (1)