After the fix of #114, it introduced a new bug that would cause the callback to never being able to be called since useFacetCallback would internally might no longer have a facet with an active subscription.
The fix makes sure that we don't reuse the same instance, with a accompanying unit test.
In the future we might want to review our decision of using a Set as it can potentially introduce issues such as this one. There has been some work on this front, but it comes with other challenges as well (potentially on performance and supporting unsubscribing as events are firing).
After the fix of #114, it introduced a new bug that would cause the callback to never being able to be called since
useFacetCallback
would internally might no longer have a facet with an active subscription.The new bug was caused by using a shared
noop
instance across all usages ofuseFacetCallback
, and it occurs because ourcreateFacet
implementation uses a given listener instance as a key to keep track of all its listeners. See: https://github.com/Mojang/ore-ui/blob/main/packages/%40react-facet/core/src/facet/createFacet.ts#L17The fix makes sure that we don't reuse the same instance, with a accompanying unit test.
In the future we might want to review our decision of using a
Set
as it can potentially introduce issues such as this one. There has been some work on this front, but it comes with other challenges as well (potentially on performance and supporting unsubscribing as events are firing).