Last active
August 29, 2015 14:13
-
-
Save Anachron/de65163808058f5dc2ff to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| App = require 'App' | |
| SingletonFactory = require 'SingletonFactory' | |
| AppFactory = {} | |
| AppFactory.get = (options) -> | |
| return SingletonFactory.getObject 'App', options | |
| AppFactory.has = () -> | |
| return SingletonFactory.hasObject 'App' | |
| } | |
| module.exports = AppFactory |
This file contains hidden or 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
| SingletonFactory = {} | |
| SingletonFactory.objects = {} | |
| SingletonFactory.getObject (className, options) -> | |
| if hasObject className then | |
| return this.objects[className] | |
| else | |
| obj = new className(options) | |
| this.objects[className] = obj | |
| return obj | |
| SingletonFactory.hasObject (className) -> | |
| return is className in SingletonFactory.objects | |
| module.exports = SingletonFactory |
This file contains hidden or 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
| AppFactory = require 'AppFactory' | |
| App = AppFactory.get() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment