OlapicBatch
Direct Subclass:
The abstract class to manage entities collections, like a media feed.
Constructor Summary
Public Constructor | ||
public |
constructor(intialUrl: String, limit: Number, rightsOnly: Boolean) The class constructor that sets the basic information for the batch, like the initial url and the batch settings. |
Member Summary
Public Members | ||
public get |
A quick shortcut to get access to the DevKit singleton. |
Method Summary
Public Methods | ||
public |
Makes a request to the API and returns a entities list, or an |
|
public |
Checks whether there's a next page to load or not. |
|
public |
Checks whether there's a previous page to load or not. |
|
public |
Loads the batch next page. |
|
public |
Loads the batch previous page. |
Public Constructors
Public Members
Public Methods
public fetch(): Promise<Array, Error> source
Makes a request to the API and returns a entities list, or an Error
if something goes
wrong.
If this method it's called before another fetch
promise is resolved, it will automatically
reject the promise with an error.
Return:
Promise<Array, Error> | If everything goes well, it will return an entities list,
otherwise, it will return an |
Example:
.fetch().then((entities) => {
for (let i = 0; i < entities.length; i++) {
console.log('Entity: ', entities[i].toString());
}
}).catch((e) => console.log('Error: ', e));
public next(): Promise<Array, Error> source
Loads the batch next page. This method returns a call to .fetch()
, so they can be
handled the same way.
You should always check first if there's a next page using .hasNextPage()
.
Return:
Promise<Array, Error> | If everything goes well, it will return an entities list,
otherwise, it will return an |
Example:
.next().then((entities) => {
for (let i = 0; i < entities.length; i++) {
console.log('Entity: ', entities[i].toString());
}
}).catch((e) => console.log('Error: ', e));
public prev(): Promise<Array, Error> source
Loads the batch previous page. This method returns a call to .fetch()
, so they can be
handled the same way.
You should always check first if there's a previous page using .hasPrevPage()
.
Return:
Promise<Array, Error> | If everything goes well, it will return an entities list,
otherwise, it will return an |
Example:
.prev().then((entities) => {
for (let i = 0; i < entities.length; i++) {
console.log('Entity: ', entities[i].toString());
}
}).catch((e) => console.log('Error: ', e));