Skip to content

Commit 0c3e9b1

Browse files
committed
[DURACOM-234] Fix NG0600 error
1 parent e0855a4 commit 0c3e9b1

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/app/core/data/request.service.spec.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
fakeAsync,
3+
flush,
34
TestBed,
45
waitForAsync,
56
} from '@angular/core/testing';
@@ -501,21 +502,23 @@ describe('RequestService', () => {
501502
dispatchSpy = spyOn(store, 'dispatch');
502503
});
503504

504-
it('should dispatch a RequestConfigureAction', () => {
505+
it('should dispatch a RequestConfigureAction', fakeAsync(() => {
505506
const request = testGetRequest;
506507
serviceAsAny.dispatchRequest(request);
508+
flush();
507509
const firstAction = dispatchSpy.calls.argsFor(0)[0];
508510
expect(firstAction).toBeInstanceOf(RequestConfigureAction);
509511
expect(firstAction.payload).toEqual(request);
510-
});
512+
}));
511513

512-
it('should dispatch a RequestExecuteAction', () => {
514+
it('should dispatch a RequestExecuteAction', fakeAsync(() => {
513515
const request = testGetRequest;
514516
serviceAsAny.dispatchRequest(request);
517+
flush();
515518
const secondAction = dispatchSpy.calls.argsFor(1)[0];
516519
expect(secondAction).toBeInstanceOf(RequestExecuteAction);
517520
expect(secondAction.payload).toEqual(request.uuid);
518-
});
521+
}));
519522

520523
describe('when it\'s not a GET request', () => {
521524
it('shouldn\'t track it', () => {

src/app/core/data/request.service.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '@ngrx/store';
99
import cloneDeep from 'lodash/cloneDeep';
1010
import {
11+
asapScheduler,
1112
from as observableFrom,
1213
Observable,
1314
} from 'rxjs';
@@ -241,7 +242,7 @@ export class RequestService {
241242
return source.pipe(
242243
tap((entry: RequestEntry) => {
243244
if (hasValue(entry) && hasValue(entry.request) && !isStale(entry.state) && !isValid(entry)) {
244-
this.store.dispatch(new RequestStaleAction(entry.request.uuid));
245+
asapScheduler.schedule(() => this.store.dispatch(new RequestStaleAction(entry.request.uuid)));
245246
}
246247
}),
247248
);
@@ -394,6 +395,7 @@ export class RequestService {
394395
const requestEntry$ = this.getByHref(href);
395396

396397
requestEntry$.pipe(
398+
filter((re: RequestEntry) => isNotEmpty(re)),
397399
map((re: RequestEntry) => re.request.uuid),
398400
take(1),
399401
).subscribe((uuid: string) => {
@@ -449,8 +451,10 @@ export class RequestService {
449451
* @param {RestRequest} request to dispatch
450452
*/
451453
private dispatchRequest(request: RestRequest) {
452-
this.store.dispatch(new RequestConfigureAction(request));
453-
this.store.dispatch(new RequestExecuteAction(request.uuid));
454+
asapScheduler.schedule(() => {
455+
this.store.dispatch(new RequestConfigureAction(request));
456+
this.store.dispatch(new RequestExecuteAction(request.uuid));
457+
});
454458
}
455459

456460
/**

0 commit comments

Comments
 (0)