Last active
August 29, 2015 13:57
-
-
Save tusharmath/9910975 to your computer and use it in GitHub Desktop.
What is the best approach to setup this view architecture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
socket.on('message', function(data) { | |
//ListView needs to be updated based on the data and the current selected tab | |
if (user_current_tab === 'special_tab_1') { | |
take_action_for_special_tab_1(data); | |
} else if (user_current_tab === 'special_tab_2') { | |
take_action_for_special_tab_2(data); | |
} else { | |
//For all other 13 cases | |
take_default_action_for_other_tabs(data); | |
} | |
//Notification view needs to be updated irrespective of the tab selected. | |
take_action_notification_view(data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One possible problem that I can think of is - what happens when you have another special tab -
special_tab_3
, which shares a part of the logic withspecial_tab_1
. One could update the code as follows -Calling the
take_action_for_special_tab_1
and telling it to execute as if we were on tab3 is just awful. Also, doesn't theif else
block seem redundant?