Skip to content

Commit

Permalink
feat(http): call complete on request complete
Browse files Browse the repository at this point in the history
closes #2635
  • Loading branch information
PatrickJS authored and jeffbcross committed Jul 28, 2015
1 parent 74b311a commit 6fac901
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/angular2/src/http/backends/xhr_backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export class XHRConnection implements Connection {
}

ObservableWrapper.callNext(this.response, new Response(responseOptions));
// TODO(gdi2290): defer complete if array buffer until done
ObservableWrapper.callReturn(this.response);
});
// TODO(jeffbcross): make this more dynamic based on body type

Expand Down
10 changes: 10 additions & 0 deletions modules/angular2/test/http/backends/xhr_backend_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ export function main() {
existingXHRs[0].dispatchEvent('load');
}));

it('should complete a request', inject([AsyncTestCompleter], async => {
var connection = new XHRConnection(sampleRequest, new MockBrowserXHR(),
new ResponseOptions({type: ResponseTypes.Error}));
ObservableWrapper.subscribe<Response>(connection.response, res => {
expect(res.type).toBe(ResponseTypes.Error);
}, null, () => { async.done(); });

existingXHRs[0].dispatchEvent('load');
}));

it('should call abort when disposed', () => {
var connection = new XHRConnection(sampleRequest, new MockBrowserXHR());
connection.dispose();
Expand Down

0 comments on commit 6fac901

Please sign in to comment.