onRequestBefore
onRequestBefore
Called immediately before a data request goes out to a Provider Instance.
Parameters
provInstName(string): The name of the Provider Instance sending the request
Returns: No return value — this is a callback, so its return value isn't used.
Description
When you call $vm.requestData(provInstName) or $vm.requestNextData(provInstName), this function runs just before the network request actually leaves. Use it to turn on a loading indicator or prepare the screen state ahead of the request.
Example
function onRequestBefore(provInstName) {
$log.i("request start: " + provInstName);
$vm.setDSValue("uiState.loading", true);
}
Related
- It's easy to confuse this with
onRequestAfter.onRequestBeforefires before the request is sent;onRequestAfterfires right after sending completes, before any response arrives. Neither has anything to do with the response itself. - Several Provider Instances can be requested at once, so always use
provInstNameto tell which request you're handling.