No, the client api doesn't provide this capability.
You have a couple options. Either do as you are doing; hard code a series of if/then/elses or switch/cases. Or you could quite easily add your own wrapper to the client library that provides it a more generic capability.
For example, the following untested code:
var subscriptions = [];
function subscribe(topic,callback) {
subscriptions.push({topic:topic,cb:callback});
mqttClient.subscribe(topic);
}
mqttClient.onMessageArrived = function(message) {
for (var i=0;i<subscriptions.length;i++) {
if (message.destinationName == subscriptions[i].topic) {
subscriptions[i].cb(message);
}
}
}
Note, this assumes you only subscribe to absolute topics - ie without wildcards. If you use wildcards, you'd have to do some regular expression matching rather than the ==
test this code uses.