SHARE
TWEET

Untitled

a guest May 25th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Singleton {
  2.     private static _instance : Singleton;
  3.     /**
  4.      * TimeUtils
  5.      */
  6.     public static get instance():Singleton {
  7.         if(!this._instance)
  8.             this._instance = new Singleton();
  9.         return this._instance;
  10.     }
  11.     private constructor(){}
  12.    
  13. }
  14.  
  15. 目前用過最簡易的 Singleton , 可以在編寫時使用 Singleton.instance 進行調用。 既有 static class 的優點,並且也屬於 instance。
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top