Home Reference Source Repository
public class | source

OlapicBatch

Direct Subclass:

OlapicMediaBatch

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 Error if something goes wrong.

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 constructor(intialUrl: String, limit: Number, rightsOnly: Boolean) source

The class constructor that sets the basic information for the batch, like the initial url and the batch settings.

Params:

NameTypeAttributeDescription
intialUrl String

The url for the batch first page.

limit Number
  • optional
  • default: 20

How many element per page will be fetched.

rightsOnly Boolean
  • optional
  • default: false

If this is true, it will only return entities with approved rights.

Public Members

public get DevKit: OlapicDevKit source

A quick shortcut to get access to the DevKit singleton.

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 Error.

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 hasNextPage(): Boolean source

Checks whether there's a next page to load or not.

Return:

Boolean

Whether there's a next page or not.

public hasPrevPage(): Boolean source

Checks whether there's a previous page to load or not.

Return:

Boolean

Whether there's a previous page or not.

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 Error.

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 Error.

Example:

.prev().then((entities) => {
    for (let i = 0; i < entities.length; i++) {
        console.log('Entity: ', entities[i].toString());
    }
}).catch((e) => console.log('Error: ', e));