Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Singleton {
- private static _instance : Singleton;
- /**
- * TimeUtils
- */
- public static get instance():Singleton {
- if(!this._instance)
- this._instance = new Singleton();
- return this._instance;
- }
- private constructor(){}
- }
- 目前用過最簡易的 Singleton , 可以在編寫時使用 Singleton.instance 進行調用。 既有 static class 的優點,並且也屬於 instance。
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement