From c06c5a36b108c6ad20776923d75eb6f32ace591b Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 30 Mar 2011 09:35:59 -0700 Subject: make xhr.cache optionally synchronous - add `sync` flag xhr.cache - change ng:include to use the sync flag - change ng:view to use the sync flag The end result is that there are fewer repaints in the browser, which means less "blinking" that user sees. --- test/service/xhr.cacheSpec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/service') diff --git a/test/service/xhr.cacheSpec.js b/test/service/xhr.cacheSpec.js index 82b33b72..0a0140a6 100644 --- a/test/service/xhr.cacheSpec.js +++ b/test/service/xhr.cacheSpec.js @@ -107,6 +107,22 @@ describe('$xhr.cache', function() { }); + it('should call callback synchronously when sync flag is on', function() { + $browserXhr.expectGET('/url').respond('+'); + cache('GET', '/url', null, callback, false, true); + expect(log).toEqual(''); //callback hasn't executed + + $browserXhr.flush(); + expect(log).toEqual('"+";'); //callback has executed + + cache('GET', '/url', null, callback, false, true); + expect(log).toEqual('"+";"+";'); //callback has executed + + $browser.defer.flush(); + expect(log).toEqual('"+";"+";'); //callback was not called again any more + }); + + it('should call eval after callbacks for both cache hit and cache miss execute', function() { var eval = this.spyOn(scope, '$eval').andCallThrough(); -- cgit v1.2.3