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

Function retrieveTransferredState

packages/core/src/transfer_state.ts:150–169  ·  view source on GitHub ↗
(
  doc: Document,
  appId: string,
)

Source from the content-addressed store, hash-verified

148}
149
150export function retrieveTransferredState(
151 doc: Document,
152 appId: string,
153): Record<string, unknown | undefined> {
154 // Locate the script tag with the JSON data transferred from the server.
155 // The id of the script tag is set to the Angular appId + 'state'.
156 const script = doc.getElementById(appId + '-state');
157 if (script?.tagName === 'SCRIPT' && script.textContent) {
158 try {
159 // Avoid using any here as it triggers lint errors in google3 (any is not allowed).
160 // Decoding of `<` is done of the box by browsers and node.js, same behaviour as G3
161 // script_builders.
162 return JSON.parse(script.textContent) as {};
163 } catch (e) {
164 console.warn('Exception while restoring TransferState for app ' + appId, e);
165 }
166 }
167
168 return {};
169}

Callers 2

getTransferStateFunction · 0.90
TransferStateClass · 0.85

Calls 2

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…