robotlegs / robotlegs-framework

An ActionScript 3 application framework for Flash and Flex
https://robotlegs.tenderapp.com/
MIT License
967 stars 261 forks source link

Multiple Mediation Order #179

Open prankard opened 8 years ago

prankard commented 8 years ago

So I've been doing a lot of multiple mediation recently (which is really cool). Just tagging a whole lot of view objects with interfaces to give it lots of new functionality/abilities.

But when doing so a lot, I've had a couple of cases where mediators need to run a particular order.

You've made a cool initialize and destroy order.

preInitialize
initialize
postInitialize
preDestroy
destroy
postDestroy

But when mediating a view with 2 mediators. The order isn't what I expected to happen. I wanted to make sure code was run a particular mediator before another one.

Here is the current order:

Mediator A - preInitialize
Mediator A - initialize
Mediator A - postInitialize
Mediator B - preInitialize
Mediator B - initialize
Mediator B - postInitialize
Mediator A - preDestroy
Mediator A - destroy
Mediator A - postDestroy
Mediator B - preDestroy
Mediator B - destroy
Mediator B - postDestroy

Can I change it like so:

Mediator A - preInitialize
Mediator B - preInitialize
Mediator A - initialize
Mediator B - initialize
Mediator A - postInitialize
Mediator B - postInitialize
Mediator A - preDestroy
Mediator B - preDestroy
Mediator A - destroy
Mediator B - destroy
Mediator A - postDestroy
Mediator B - postDestroy

I'm working on the code now, but wanted to make sure there wasn't a reason for the previous method.

ivan-shaban commented 8 years ago

Hi, how about implement that behaviour like a toggled feature (e.g. in mediator map)? I think in some cases first behaviour a useful, and in other the second?