So I have some code in a service that looks like this:
getData(params) {
// ... config, url
return this.$http.get(url, config)
.then(result => {...})
.catch((e) => {...})
}
And I use it in a component like so:
ctrl.service.getData(params).then(result => {...}).catch((e) => {...})...;
The thing is, I want to be able the cancel this promise, something that can be achieved fairly easy using Bluebird. But if I wrap my $http call in a Promise.resolve($http...)
then I'm missing out on the digest cycle triggered by the $http call and my UI doesn't get updated. Is there a better way to return Bluebird promise from the service ?
EDIT: I wrapped my call like so.
getData(params) {
// ... config, url
return Promise.resolve( this.$http.get(url, config) )
.then(result => {...})
.catch((e) => {...})
}
This is returning me the needed bluebird promise and I am able to cancel it, but this fires up the angularjs $digest before I'm finished consuming the promise inside the controller, so the UI does not get updated. (I do not want to call a $scope.$apply)