MCPcopy Index your code
hub / github.com/angular/angular / getInitialStream

Function getInitialStream

packages/common/http/src/resource.ts:251–271  ·  view source on GitHub ↗
(req: HttpRequest<unknown> | undefined)

Source from the content-addressed store, hash-verified

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,

Callers 1

constructorMethod · 0.85

Calls 4

retrieveStateFromCacheFunction · 0.90
signalFunction · 0.90
parseMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…