Created
March 30, 2011 23:24
-
-
Save shinypb/895515 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
/* Assume that this component exists somewhere: */ | |
twttr.klass('twttr.components.Person', function(name, location) { | |
this.name = name; | |
this.location = location; | |
}); | |
/* A few ideas for asyncronous instantiation: */ | |
// 1. Pass variable number of constructor arguments and callback as the last argument | |
var callback = function(instance) { | |
console.log('Now I have an instance:', instance); | |
}; | |
twttr.new('twttr.components.Person', name, location, callback); | |
// 2. Pass constructor arguments as an array and then a callback | |
twttr.new('twttr.components.Person', [name, location], callback); | |
// 3. Callback passed to .ready event | |
twttr.new('twttr.components.Person', name, location).ready(callback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment