(req: HttpRequest<unknown> | undefined)
| 249 | const originMap = injector.get(HTTP_TRANSFER_CACHE_ORIGIN_MAP, null, {optional: true}); |
| 250 | |
| 251 | const getInitialStream = (req: HttpRequest<unknown> | undefined) => { |
| 252 | if (cacheOptions && transferState && req) { |
| 253 | const cachedResponse = retrieveStateFromCache(req, cacheOptions, transferState, originMap); |
| 254 | if (cachedResponse) { |
| 255 | try { |
| 256 | const body = cachedResponse.body as TRaw; |
| 257 | const parsed = options?.parse ? options.parse(body) : (body as unknown as TResult); |
| 258 | return signal({value: parsed}); |
| 259 | } catch (e) { |
| 260 | if (typeof ngDevMode === 'undefined' || ngDevMode) { |
| 261 | console.warn( |
| 262 | `Angular detected an error while parsing the cached response for the httpResource at \`${req.url}\`. ` + |
| 263 | `The resource will fall back to its default value and try again asynchronously.`, |
| 264 | e, |
| 265 | ); |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | return undefined; |
| 271 | }; |
| 272 | |
| 273 | return new HttpResourceImpl( |
| 274 | injector, |
no test coverage detected
searching dependent graphs…