[css-regions] Async events, events coalescing, magic stuffs

This one is funny:

Suppose I'm a layout manager which use regions. I want to know when the layout of my regions is updated because I want to post-process the result.

My pattern would be:

- mark my stuff as invalidated
- stop listening to region events
- queue a microtask for recomputation:
--- get the current region layout properties I need
--- do my stuff, which will possibly trigger one of more region relayout
--- force the layout to happen by doing something fancy like asking for an offsetHeight
--- at this point, everything is done, so...
--- add new event listeners to the region events to cover next updates

In the [css-regions] spec, it's being written that region events are async. Async in which way?

The question is: 

- Will the event listeners I added at the end of my process get possibly notified for the changes that did happen before they were set up? because if they do, I just created an infinite loop... if not, is there any way I can know for sure the event I get does not only cover stuff that happened before I started listening? timestamps maybe?




Another question:

- If I update the layout of my region 10 times, should I expect 10 events or may the events be coalesced to just one if they fire after the 10 relayouts? 		 	   		  

Received on Tuesday, 30 July 2013 21:24:38 UTC