Skip to content

Instantly share code, notes, and snippets.

@shadeglare
Created November 22, 2015 12:24
Show Gist options
  • Save shadeglare/ffeff47100fec3e5f2d1 to your computer and use it in GitHub Desktop.
Save shadeglare/ffeff47100fec3e5f2d1 to your computer and use it in GitHub Desktop.
export module Singleton {
export function create<T>(creator: () => T) {
let instance: T = null;
return {
get Instance() {
if (Check.isNullOrUndefined(instance)) {
instance = creator();
}
return instance;
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment