hook not work there? I don't really understand the use case of
onPreCommit
.
a
Adam Powell
07/14/2020, 4:49 PM
The distinction is probably going away soon. The difference is that
onCommit
posts the event to happen "a bit later" rather than as we're actually applying the changes to the composition. The direction we're leaning in is that the current deferred
onCommit
behavior will go away and only the
onPreCommit
behavior will remain.
👍🏼 1
Adam Powell
07/14/2020, 4:50 PM
so the reason this is using
onPreCommit
is just a minor latency and timing improvement over
onCommit
.
j
Julius Marozas
07/14/2020, 5:09 PM
Oh, okay. So the reason they were made separate was
not to overwhelm compose with not as crucial events (and put those in
onCommit
)?
a
Adam Powell
07/14/2020, 6:08 PM
no, the reason they were made separate is partially historical and had to do with whether it was risky or not to execute side effects of a composition while the process of applying them was still in progress, vs. after all of them have been completely applied.
Adam Powell
07/14/2020, 6:10 PM
Some internal dispatching logic around this changed and the
onPreCommit
path is already "deferred" until after all tree changes happen, but it doesn't yield to a system handler/scheduler to do it, which avoids ordering questions and a small amount of latency.