I am using Websocket (javascript) which has the following events:
ctrlScope.conn.onerror = function() {
ctrlScope.updateStatus();
};
ctrlScope.conn.onclose = function() {
ctrlScope.updateStatus();
};
ctrlScope.conn.onopen = function() {
ctrlScope.updateStatus();
};
As you can see I am updathing the chat status using those events, but it looks repetative, is there any way to combine all those Websocket events in one?
ctrlScope.conn[onError][onClose][onOpen] = function() {
ctrlScope.updateStatus();
};
Additionally there is a Websocket variable: readyState which provides the status of the connection same as the events. This could replace the functions hassle, but $watch does not work on it.
Please some one help :(