Documentation: if you are explaining a concept, make the demo code *the bare minimum to illustrate the point*
Do not add in any other code.
Do not make it more complicated than that, until the concept is understood.
Every line of the sample code should relate directly and only to the concept being discussed.
This is not how to do it: https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver because it requires parsing all the other crap the code is doing.
@mattwilcox if you create an observer per element you wish to observe you get the pattern you describe.
Yet if the API woked the way you describe you could not apply the same logic to a collection of elements.
The bigger trip up I've hit with these APIs has been around the callback closure lifetimes and React crapiness.