-
Notifications
You must be signed in to change notification settings - Fork 0
Book
Chris Willoughby edited this page Oct 23, 2015
·
5 revisions
Trove.Book is a class used to hold metadata on a book. It is a subclass of Trove.Work.
It can be constructed with an init argument to request the data immediately:
var my_book = new Trove.Book({
init: 9920934,
done: function(book) {
console.log(JSON.stringify(book, null, '\t'));
}
});
or you can use the get() method to request the data at some later time:
var my_book = new Trove.Book({
done: function(book) {
console.log(JSON.stringify(book, null, '\t'));
}
});
my_book.get({id: 9920934});
If you want to re-request data, perhaps with more included information, just call get() again with the includes and/or reclevel options (the id parameter is optional if specified earlier):
my_book.get({
id: 9920934,
reclevel: Trove.RECLEVEL.FULL
});
You can also specify these on construction:
function book_done (book) {
console.log(JSON.stringify(book, null, '\t'));
}
var my_book = new Trove.Book({
init: 9920934,
reclevel: Trove.RECLEVEL.FULL,
includes: [Trove.INCLUDE.TAGS, Trove.INCLUDE.COMMENTS],
done: book_done
});
The done and fail callbacks can be set via the options on construction or on the get() method. If set with the get() method after being set on construction, the new callbacks will be used from there on.