File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -393,6 +393,14 @@ class HttpResourceImpl<T>
393
393
this . client = injector . get ( HttpClient ) ;
394
394
}
395
395
396
+ override set ( value : T ) : void {
397
+ super . set ( value ) ;
398
+
399
+ this . _headers . set ( undefined ) ;
400
+ this . _progress . set ( undefined ) ;
401
+ this . _statusCode . set ( undefined ) ;
402
+ }
403
+
396
404
// This is a type only override of the method
397
405
declare hasValue : ( ) => this is HttpResourceRef < Exclude < T , undefined > > ;
398
406
}
Original file line number Diff line number Diff line change @@ -323,4 +323,19 @@ describe('httpResource', () => {
323
323
req = backend . expectOne ( '/data' ) ;
324
324
req . flush ( [ ] ) ;
325
325
} ) ;
326
+
327
+ it ( 'should reset past request data when using set()' , async ( ) => {
328
+ const backend = TestBed . inject ( HttpTestingController ) ;
329
+ const res = httpResource ( ( ) => '/data' , { injector : TestBed . inject ( Injector ) } ) ;
330
+ TestBed . tick ( ) ;
331
+ const req = backend . expectOne ( '/data' ) ;
332
+ req . flush ( [ ] ) ;
333
+ await TestBed . inject ( ApplicationRef ) . whenStable ( ) ;
334
+
335
+ res . set ( [ ] ) ;
336
+
337
+ expect ( res . headers ( ) ) . toBe ( undefined ) ;
338
+ expect ( res . progress ( ) ) . toBe ( undefined ) ;
339
+ expect ( res . statusCode ( ) ) . toBe ( undefined ) ;
340
+ } ) ;
326
341
} ) ;
You can’t perform that action at this time.
0 commit comments