Skip to content

Instantly share code, notes, and snippets.

@pwmckenna
pwmckenna / func.btapp.js
Created October 1, 2012 07:38
Wrap a potentially unavailable Btapp function to make it immediately callable
/**
Usage:
var add = btapp.func('add', 'torrent');
...or to provide a callback for dht activity, you might try the following:
var get_any_hash = btapp.func('dht', 'get_any_hash');
// While the function won't be available immediately, it is abstracted away,
// allowing you to treat the future function as immedidately callable
get_any_hash(function(hash) {
//Just saw a hash in the dht!
});