Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 25c6a21

Browse files
authored
fix: simulated HTTP errors now delayed as expected (#182)
closes #180 also fixes type error (#180)
1 parent f673b1c commit 25c6a21

17 files changed

+8153
-21
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@ because this is a development tool, not a production product.
88
We do try to tell you about such changes in this `CHANGELOG.md`
99
and we fix bugs as fast as we can.
1010

11-
<a id="0.5.2"></a>
11+
<a id="0.5.4"></a>
12+
## 0.5.4 (2018-03-09)
13+
14+
Simulated HTTP error responses were not delaying the prescribed time when using RxJS `delay()`
15+
because it was short-circuited by the ErrorResponse.
16+
New `delayResponse` function does it right.
17+
Should not break you unless you incorrectly expected no delay for errors.
18+
19+
Also, this library no longer calls RxJS `delay()` which may make testing with it easier
20+
(Angular TestBed does not handle RxJS `delay()` well because that operator uses `interval()`).
21+
22+
Also fixes type error (issue #180).
23+
24+
<a id="0.5.3"></a>
1225
## 0.5.3 (2018-01-06)
1326
Can make use of `HttpParams` which yields a `request.urlWithParams`.
1427
Added supporting `HeroService.searchHeroes(term: string)` and test.

backend.service.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend.service.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundles/in-memory-web-api.umd.js

Lines changed: 32 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

delay-response.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { Observable } from 'rxjs/Observable';
2+
/** adds specified delay (in ms) to both next and error channels of the response observable */
3+
export declare function delayResponse<T>(response$: Observable<T>, delayMs: number): Observable<T>;

delay-response.js

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

delay-response.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

delay-response.metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"__symbolic":"module","version":3,"metadata":{"delayResponse":{"__symbolic":"function","parameters":["response$","delayMs"],"value":{"__symbolic":"error","message":"Function call not supported","line":5,"character":27}}}},{"__symbolic":"module","version":1,"metadata":{"delayResponse":{"__symbolic":"function","parameters":["response$","delayMs"],"value":{"__symbolic":"error","message":"Function call not supported","line":5,"character":27}}}}]

http-client-backend.service.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HttpBackend, HttpHeaders, HttpRequest, HttpResponse, HttpXhrBackend, XhrFactory } from '@angular/common/http';
1+
import { HttpBackend, HttpEvent, HttpHeaders, HttpRequest, HttpResponse, HttpXhrBackend, XhrFactory } from '@angular/common/http';
22
import { Observable } from 'rxjs/Observable';
33
import { InMemoryBackendConfigArgs, InMemoryDbService, ResponseOptions } from './interfaces';
44
import { BackendService } from './backend.service';
@@ -32,7 +32,7 @@ import { BackendService } from './backend.service';
3232
export declare class HttpClientBackendService extends BackendService implements HttpBackend {
3333
private xhrFactory;
3434
constructor(inMemDbService: InMemoryDbService, config: InMemoryBackendConfigArgs, xhrFactory: XhrFactory);
35-
handle(req: HttpRequest<any>): Observable<HttpResponse<any>>;
35+
handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
3636
protected getJsonBody(req: HttpRequest<any>): any;
3737
protected getRequestMethod(req: HttpRequest<any>): string;
3838
protected createHeaders(headers: {

http-client-backend.service.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)