MCPcopy
hub / github.com/angular/angular / provideClientHydration

Function provideClientHydration

packages/platform-browser/src/hydration.ts:244–312  ·  view source on GitHub ↗
(
  ...features: HydrationFeature<HydrationFeatureKind>[]
)

Source from the content-addressed store, hash-verified

242 * @publicApi 17.0
243 */
244export function provideClientHydration(
245 ...features: HydrationFeature<HydrationFeatureKind>[]
246): EnvironmentProviders {
247 const providers: Provider[] = [];
248 const featuresKind = new Set<HydrationFeatureKind>();
249
250 for (const {ɵproviders, ɵkind} of features) {
251 featuresKind.add(ɵkind);
252
253 if (ɵproviders.length) {
254 providers.push(ɵproviders);
255 }
256 }
257
258 const hasHttpTransferCacheOptions = featuresKind.has(
259 HydrationFeatureKind.HttpTransferCacheOptions,
260 );
261
262 if (typeof ngDevMode !== 'undefined' && ngDevMode) {
263 if (featuresKind.has(HydrationFeatureKind.NoHttpTransferCache) && hasHttpTransferCacheOptions) {
264 throw new RuntimeError(
265 RuntimeErrorCode.HYDRATION_CONFLICTING_FEATURES,
266 'Configuration error: found both withHttpTransferCacheOptions() and withNoHttpTransferCache() in the same call to provideClientHydration(), which is a contradiction.',
267 );
268 }
269 if (
270 featuresKind.has(HydrationFeatureKind.IncrementalHydration) &&
271 featuresKind.has(HydrationFeatureKind.NoIncrementalHydration)
272 ) {
273 throw new RuntimeError(
274 RuntimeErrorCode.HYDRATION_CONFLICTING_FEATURES,
275 'Configuration error: found both withIncrementalHydration() and withNoIncrementalHydration() in the same call to provideClientHydration(), which is a contradiction.',
276 );
277 }
278 }
279
280 return makeEnvironmentProviders([
281 typeof ngDevMode !== 'undefined' && ngDevMode
282 ? provideEnabledBlockingInitialNavigationDetector()
283 : [],
284 typeof ngDevMode !== 'undefined' && ngDevMode ? provideStabilityDebugging() : [],
285 withDomHydration(),
286 featuresKind.has(HydrationFeatureKind.NoHttpTransferCache) || hasHttpTransferCacheOptions
287 ? []
288 : ɵwithHttpTransferCache({}),
289 featuresKind.has(HydrationFeatureKind.NoIncrementalHydration)
290 ? []
291 : ɵwithIncrementalHydration(),
292 providers,
293 {
294 provide: CACHE_ACTIVE,
295 useValue: {isActive: true},
296 },
297 {
298 provide: APP_BOOTSTRAP_LISTENER,
299 multi: true,
300 useFactory: () => {
301 const appRef = inject(ApplicationRef);

Callers 15

main.tsFile · 0.90
ssrFunction · 0.90
hydrateFunction · 0.90
app.config.tsFile · 0.90
app.module.tsFile · 0.90
app.config.tsFile · 0.90
app.config.tsFile · 0.90
main.tsFile · 0.90
app.config.tsFile · 0.90

Calls 10

makeEnvironmentProvidersFunction · 0.90
injectFunction · 0.90
withDomHydrationFunction · 0.85
addMethod · 0.65
hasMethod · 0.65
thenMethod · 0.65
whenStableMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…