robotlegs/robotlegs-framework — comment on commit 7762f9e12906f03ccf02f2ec6dfa8cca3214a7ce
File: src/robotlegs/bender/extensions/mediatorMap/impl/DefaultMediatorManager.as line 100
By Stray:

Ok - I've confirmed that the TileList component in AS3 has a similar bug.

If you have a library MC attached in the component and then you scroll the list such that a new item begins to appear (even though the top items are still taking up most of the visible area), those visible items are removed and then re-added to the display list.

There are also some bugs with the Scrollpane when it contains dynamic content - one way of getting around these is to reset the source to the existing source - which causes the added / removed cycle.

However - the number of people using these components might be quite small.

In a stateless mediator it becomes mostly irrelevant, unless you have hooks running - so at that point it's largely a performance-fix. However, you only need a reference to the view's parent in the mediator and suddenly you've got a dodgy value.

Of course we also run into the same issues in some ways as we had with dynamic matchers with the guard clauses - do or don't guards get reapplied during local reparenting? (I'm going to define local reparenting as being removed and added within one frame, and the roots of this mediator map still containing you afterwards - so, the overall mapping is still valid.)

What's the least surprising thing to happen? And (secondary) - what's efficient? And are they the same thing?

The Mediator itself can deal with the eventMap pause/resume issue that was causing false positives or false negatives (depending on which way we set it up) in RL1. So - we could provide a property in our Mediator which allows you to specify that it doesn't persist during reparenting.

This would allow us to say something like:

1. The default behaviour is that if a view item is reparented and remains within the contextView that it was originally mediated in, nothing will happen. This is a 'local' reparenting.

2. If a view item is reparented outside of the contextView that it was originally mediated in, it will be destroyed and a new mediator will be created (guards permitting, and hooks will be reapplied). This cannot be overridden because the scope of the eventMap and other injections may no longer be valid.

3. If you want guards/hooks to be reapplied during local reparenting, or you want your mediator to be cleaned up and re-initialised during local reparenting, specify this in your mediator by setting destroyOnReparent = true; (Need to look at what would work best with duck typing here but something like this.)

How does that sound? Do we need a discussion thread for this?