Created
May 27, 2010 05:48
-
-
Save rightjs/415511 to your computer and use it in GitHub Desktop.
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
// you could use the shared module feature | |
var SharedModule = { | |
callback: function() { | |
/// .... | |
} | |
}; | |
var Dog = new Class({ | |
include: SharedModule, | |
bark: function() { | |
.... | |
} | |
}); | |
var dog = new Dog(); | |
// but in reality you don't need all those, | |
// there is a method called 'bind' for functions | |
$('element').onClick(dog.bark.bind(dog)); | |
// check this tutorial http://rightjs.org/tutorials/functional-programming | |
// then if you'll try RightJS from master, | |
// you can prebind your methods automatically like that | |
var Dog = new Class({ | |
prebind: ['bark'] | |
bark: function() { | |
} | |
}); | |
var dog = new Dog(); | |
$('element').onClick(dog.bark); | |
// and finally RightJS has a shortctut | |
$A(arguments); | |
// which is the same as | |
Array.prototype.slice.call(arguments); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment