Badcreature / mad-components

Automatically exported from code.google.com/p/mad-components
0 stars 0 forks source link

UIPages and subclasses change? #38

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This is something that's been going around my head for some days, although I've 
not settled down on anything.

The current change of pages in a navigation container could be improved, right 
now only a couple of events are dispatched (change and complete), and from my 
experience this is somewhat limited. One can get the desired features with 
what's available right now, but this could come out of the box with the 
framework.

One way of improving this would be to make each "page" to dispatch events, 
instead of the container. I think this is a more proper way of knowing when the 
old page is being removed, and completely removed, and when the new page is 
being added and completely added. The problem with this approach, since a page 
can be "anything" is that some documentation is being lost, and it would be a 
breaking change (I think keeping old code is what causes projects to end being 
fat).

Another advantage this has is that it could, in some cases, improve an app 
performance, since we know if we need to dispatch an event, we may only launch 
events for some of our pages, instead of all of them like the current model 
does.

Well, this is just something bugging me lately.

Original issue reported on code.google.com by neverbi...@gmail.com on 22 Aug 2012 at 11:58

GoogleCodeExporter commented 8 years ago
As an example of code, instead of having:

                default:            _lastPage.visible = false;
                                    _lastPage = null;
                                    dispatchEvent(new Event(Event.CHANGE));
                                    dispatchEvent(new Event(COMPLETE));

We'd have:

                default:            _lastPage.visible = false;
                                    if (_lastPage.willTrigger(REMOVING))
                                        _lastPage.dispatchEvent(new Event(REMOVING));
                                    if (_lastPage.willTrigger(REMOVED))
                                        _lastPage.dispatchEvent(new Event(REMOVED));
                                    _lastPage = null;
                                    if (_thisPage.willTrigger(Event.CHANGE))
                                        _thisPage.dispatchEvent(new Event(Event.CHANGE));
                                    if (_thisPage.willTrigger(COMPLETE))
                                        _thisPage.dispatchEvent(new Event(COMPLETE));

I know it looks uglier at a first glance, but it allows more control over the 
views lifecycle.

Original comment by neverbi...@gmail.com on 23 Aug 2012 at 12:04

GoogleCodeExporter commented 8 years ago

Original comment by doc.andr...@gmail.com on 3 Sep 2012 at 2:50