Created
April 8, 2026 13:34
-
-
Save bh3605/94cfe9b22a4b0d400559ea3e6422f61c to your computer and use it in GitHub Desktop.
Singleton service decorator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ɵgetInjectableDef } from "@angular/core"; | |
| export function Harden(target: any) { | |
| let def = ɵgetInjectableDef(target) as any; | |
| const realFactory = def.factory; | |
| let value = undefined as any | undefined; | |
| def.factory = () => { value = value == undefined ? realFactory() : value; return value; }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment