I’m implementing a react hook wrapping “ResizeObserver”.
If I’m understanding ResizeObserver correctly you create an instance passing a callback that receives an array of ResizeObserverEntry’s
You then have to call the instance “observe” method and pass it an element to be observed.
The hook should create a single instance internally and call the appropriate callbacks for each hook use.
The thing is that I think I can’t escape having to compare the DOM element passed in the observe method to some data structure holding the element’s passed to the hook itself so…
Long story short…
What’s the proper way of comparing objects (for equality) in rescript?
Is there a data structure that can hold object references as keys?
Sorry for the obvious questions but sometimes I get insecure about the “proper way” to do things in ReScript.
Meanwhile I found Belt.MutableMap that seems to accept any type of key but I’m having some trouble understanding the docs.
Would it be a good option to use MutableMap or should I stick with iterating over an array to find the appropriate entry?
Aren’t Js.Dict keys always strings?
I managed to create a Belt.MutableMap using Dom.Element as keys but that “Belt.Id.MakeComparable” functor thing is still a little confusing but it seems to be working