Mojang / ore-ui

💎 Building blocks to construct game UIs using web tech.
https://react-facet.mojang.com/
MIT License
404 stars 19 forks source link

Fix useFacetCallback having outdated values #114

Closed pirelenito closed 1 year ago

pirelenito commented 1 year ago

The unit test demonstrates how the issue can happen, but basically if we have as the result of a subscription that a callback from a useFacetCallback is called, it could have outdated values.

This would happen simply because the order of the subscriptions could have the internal subscription inside the useFacetCallback be notified after everything else.

An implication of this change, is that the call to get will re-execute any transformations done by a useFacetMap but I don't expect this to be of a concern.

The useFacetRef will potentially have the same issue, but we can investigate and address in a follow-up PR.

Shenato commented 1 year ago

This looks good to me! great find!