Skip to content

Instantly share code, notes, and snippets.

@YannickGagnon
Last active December 17, 2015 01:09
Show Gist options
  • Save YannickGagnon/5525891 to your computer and use it in GitHub Desktop.
Save YannickGagnon/5525891 to your computer and use it in GitHub Desktop.
Moobile ViewController Delegate Pattern
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