Remember the order of arguments is annoying when using a library. Obviously JS doesn't have named args, so a lot of times people will pass an object with named properties.
thoonk.subscribe(function(id, item) {
//publish event
},
function(id, item) {
//edit event
},
function(id) {
//retract event
},
function(id, position) {
//position event for sorted feed
//position is begin:, :end, :X, X: where X is the relative id
},
function() {
//subscription ready
});
Say I only care about retractions? Then I'd have to pass null for all the others. You could instead do:
thoonk.subscribe({
retract: function () {
// my retract callback
},
add: function () {
// my add callback
}
});
Remember the order of arguments is annoying when using a library. Obviously JS doesn't have named args, so a lot of times people will pass an object with named properties.
Say I only care about retractions? Then I'd have to pass null for all the others. You could instead do: