Created
November 16, 2012 13:01
-
-
Save alanshaw/4087172 to your computer and use it in GitHub Desktop.
Compiled CoffeeScript from https://gist.github.com/4085837
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
var Foo, singletonFoo; | |
Foo = (function() { | |
var _this = this; | |
function Foo() {} | |
Foo.instance = (function() { | |
var instance; | |
instance = null; | |
return function() { | |
if (!instance) { | |
instance = new Foo(); | |
} | |
return instance; | |
}; | |
})(); | |
return Foo; | |
}).call(this); | |
singletonFoo = Foo.instance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment