On 8/29/16, 5:54 AM, "CodeGirl" <[email protected]> wrote:

>The difference was that I was
>going to push up the colorchange event on the click for the tab rather
>then
>the Navigator and then check to see if its the roof tab.  Is there a
>reason
>why you chose the navigator instead of the tab itself?
>

Hmm.  Not sure what you mean.  A Tab is just a button on top of the
TabNavigator.  There is already logic to determine which NavigatorContent
was selected.  Also, I don't like "pushing" an event up.  IMO, at each
level it should be promoted to an event with more meaning so a
"colorChange" becomes a "roofColorChange" using logic encapsulated in the
component that knows which colorChange should becomes a roofColorChange.

Otherwise, you end up with logic higher up that looks like:
if (event.type == "colorChange")
{
  if (event.target == OptionsView)
    // this is a roofColorChange
}

There is no need to do that second test when things are properly
encapsulated, plus the higher logic doesn't need to have a hard reference
to OptionsView.  Then if you decide to swap out OptionsView for
SuperOptionsView, you don't have to change this logic.

HTH,
-Alex

Reply via email to