I'm trying to find a way to cancel BreezeJS queries for the purpose of implementing a live search that queries BreezeJS on keypress (see my other question).
I know that in Angular, $http
requests can be cancelled by passing a promise to the timeout
parameter in the config
object, and then calling resolve()
on that promise.
I also know that I can get BreezeJS to use my module's $http
insance with:
var ajax = breeze.config.initializeAdapterInstance('ajax', 'angular');
ajax.setHttp($http);
So I was thinking about possibly creating a request
interceptor on $http
that would set config.timeout
to a promise. But that still leaves me quite a few steps away from solving the problem, because I would somehow need to be able to give the promise to my interceptor from the code running the query (so that the querying code could resolve()
the promise if needed).
Is there a better way? Is it even possible?