The parameter which is passed to
Do not use switch/case, else if, or any other construct that matches at most one branch. These will silently drop every update whose type happens to come after an earlier match.
Correct:
Framework.OnMessage = function(Msg) {
if (Msg.is(FXB.MessageTypes.PRICE)) {
// ... update a quote board
}
if (Msg.is([FXB.MessageTypes.ORDER_OPEN, FXB.MessageTypes.ORDER_CLOSE])) { // ... update a trade list
}
};
Incorrect -
Framework.OnMessage = function(Msg) {
if (Msg.is(FXB.MessageTypes.PRICE)) {
// ...
} else if (Msg.is([FXB.MessageTypes.ORDER_OPEN, FXB.MessageTypes.ORDER_CLOSE])) {
// ... NEVER REACHED when the message also contains a PRICE update
}
};
Incorrect -
Framework.OnMessage = function(Msg) {
switch (Msg.type) { // Msg does not have a single "primary" type case FXB.MessageTypes.PRICE:
// ... break;
case FXB.MessageTypes.ORDER_OPEN:
// ... NEVER REACHED when the message also contains a PRICE update break;
}
};