(cacheKey: any, moduleName: string, appName: string, fn: () => T, deps: any)
| 1 | import { isDevMode } from '@angular/core'; |
| 2 | |
| 3 | export 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 | |
| 18 | function matchDep(a: any, b: any) { |
| 19 | try { |
no test coverage detected