Created
November 12, 2019 15:40
-
-
Save tomeustace/334c9777b9e26617eff464b8ef64997e to your computer and use it in GitHub Desktop.
Angular decorator for overriding ngoninit, maybe extended to avoid multiple component instances
This file contains 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
export function Singleton() { | |
return function(target, key, decorator) { | |
const method = decorator.value; | |
const myOverride = () => { | |
// do stuff | |
method.call(); | |
} | |
decorator.value = myOverride; | |
return decorator; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment