Example
var asyngleton = fs = ; //called ONCEvar readDir = //initializes the singleton method above //called after there's a result;
API
asyngleton(factory)
Creates a new asyngleton function.
factory
- the factory method for creating the singleton. This is called ONCE.
.reset()
Resets the target asyngleton so the factory can be called again.
var fs = asyngleton = ; var readDir = ; ;
.dictionary()
creates a dictionary of singletons
var dict = fs = ; var readThisDir = dict; var readLibDir = dict ; ;
dictionary.get(name, factory)
name
- the name of the singleton in the dictionaryfactory
- the factory method incase the singleton doesn't exist
Structr Integration
var structr = ;structr; var TestClass = ; var test = ; test; //fs.readFile is NOT called again at this pointtest;