Created
September 11, 2020 19:15
-
-
Save Dornhoth/6896c0602ca6f3dfa485d2395bb841bb to your computer and use it in GitHub Desktop.
Singleton
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 { Injectable } from '@angular/core'; | |
@Injectable() | |
export class SingletonService { | |
static instances = 0; | |
constructor() { | |
SingletonService.instances += 1; | |
} | |
someMethod(): void { | |
console.log(`There are ${SingletonService.instances} instances of the service`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment