angularjs - Find duration of a REST call in Angular.js -
i want find out time taken rest service send promise object. if rest service takes more lets x seconds, need show user spinner , once promise object obtained normal flow should proceed.
any ideas?
thanks
recording time of request seems unnecessary.
why not setup timeout trigger spinner after x seconds. in success callback of promise can destroy timeout object preventing triggering spinner if it's before x seconds. remove spinner if exists.
var duration = 1000 * 1; //1 sec var timeout = settimeout(releasethespinner, duration); var releasethespinner = function() { //make spinner } something.update(data). success(function { cleartimeout(timeout); //kill spinner })
Comments
Post a Comment