MCPcopy
hub / github.com/angular/angularfire / ɵcacheInstance

Function ɵcacheInstance

src/compat/cache.ts:3–16  ·  view source on GitHub ↗
(cacheKey: any, moduleName: string, appName: string, fn: () => T, deps: any)

Source from the content-addressed store, hash-verified

1import { isDevMode } from '@angular/core';
2
3export function ɵcacheInstance<T>(cacheKey: any, moduleName: string, appName: string, fn: () => T, deps: any): T {
4 const [, instance, cachedDeps] = globalThis.ɵAngularfireInstanceCache.find((it: any) => it[0] === cacheKey) || [];
5 if (instance) {
6 if (!matchDep(deps, cachedDeps)) {
7 log('error', `${moduleName} was already initialized on the ${appName} Firebase App with different settings.${IS_HMR ? ' You may need to reload as Firebase is not HMR aware.' : ''}`);
8 log('warn', {is: deps, was: cachedDeps});
9 }
10 return instance;
11 } else {
12 const newInstance = fn();
13 globalThis.ɵAngularfireInstanceCache.push([cacheKey, newInstance, deps]);
14 return newInstance;
15 }
16}
17
18function matchDep(a: any, b: any) {
19 try {

Callers 9

constructorMethod · 0.90
constructorMethod · 0.90
ɵauthFactoryFunction · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90

Calls 4

matchDepFunction · 0.85
fnFunction · 0.85
pushMethod · 0.80
logFunction · 0.70

Tested by

no test coverage detected