Last active
December 17, 2015 01:09
-
-
Save YannickGagnon/5525891 to your computer and use it in GitHub Desktop.
Moobile ViewController Delegate Pattern
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
Class.refactor(Moobile.ViewController, { | |
_delegate: null, | |
setDelegate: function(delegate) { | |
this._delegate = delegate; | |
}, | |
respondsToFunction: function(functionName) { | |
return typeof this._delegate[functionName] === 'function'; | |
}, | |
performFunction: function() { | |
var args = Array.prototype.slice.call(arguments); | |
var functionName = args.shift(); | |
this._delegate[functionName].apply(this._delegate, args); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment