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: developer.mozilla.org/en-US/do because it requires parsing all the other crap the code is doing.

Tangentially - I don't like the Resize Observer API because of how it splits the observing from the element.

I don't want to hand "an observer" a ton of elements and then have to operate inside that observer collection to decide what to do on "each" element.

I just want to say "for *this div* watch it resize and then do XYZ based on that" far more succinctly.

This is a mess.

Follow

@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.

Sign in to participate in the conversation
Mastodon

Time for a cuppa... Earl Grey please!