Skip to content

Instantly share code, notes, and snippets.

@kevjose
Created January 14, 2017 13:48
Show Gist options
  • Select an option

  • Save kevjose/25bec07393aec6f89e00afc24dc12d15 to your computer and use it in GitHub Desktop.

Select an option

Save kevjose/25bec07393aec6f89e00afc24dc12d15 to your computer and use it in GitHub Desktop.
function MyConstructor(data, transport) {
this.data = data;
transport.on('data', function () {
alert(this.data);
});
}
// Mock transport object
var transport = {
on: function(event, callback) {
setTimeout(callback, 1000);
}
};
// called as
var obj = new MyConstructor('foo', transport);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment