As i know that angular watches are evaluated in every digest loop. So, i need such kind of function in core javascript for watch http response json object.
Somethings like this:-
var oldResponseData='{"name":"Ram","age":"45"}';
function myCustomeWatch(httpResponseData){
if(httpResponseData===oldResponseData){
return false;
}else{
oldResponseData=httpResponseData;
}
}
.
.
.
httpResponseData='{"name":"Ram","age":"46"}';//'{"name":"Ram","age":"45"}' != '{"name":"Ram","age":"46"}'
setInterval(function(){
myCustomeWatch(httpResponseData);
},3000);
You can also use Object.watch. More info is available here
And here is the polyfill for ES5 compatible browsers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With