Commit 236bb933 authored by Filipa Lacerda's avatar Filipa Lacerda

Changes after review

parent 9f7c19b3
......@@ -8,10 +8,10 @@ import httpStatusCodes from './http_status';
* new Poll({
* resource: resource,
* method: 'name',
* data: {page: 1, scope: 'all'},
* data: {page: 1, scope: 'all'}, // optional
* successCallback: () => {},
* errorCallback: () => {},
* auxiliarCallback: () => {},
* notificationCallback: () => {}, // optional
* }).makeRequest();
*
* Usage in pipelines table with visibility lib:
......@@ -22,7 +22,7 @@ import httpStatusCodes from './http_status';
* data: { page: pageNumber, scope },
* successCallback: this.successCallback,
* errorCallback: this.errorCallback,
* auxiliarCallback: this.updateLoading,
* notificationCallback: this.updateLoading,
* });
*
* if (!Visibility.hidden()) {
......@@ -48,6 +48,8 @@ export default class Poll {
constructor(options = {}) {
this.options = options;
this.options.data = options.data || {};
this.options.notificationCallback = options.notificationCallback ||
function notificationCallback() {};
this.intervalHeader = 'POLL-INTERVAL';
this.timeoutID = null;
......@@ -68,10 +70,10 @@ export default class Poll {
}
makeRequest() {
const { resource, method, data, errorCallback, auxiliarCallback } = this.options;
const { resource, method, data, errorCallback, notificationCallback } = this.options;
// It's called everytime a new request is made. Useful to update the status.
auxiliarCallback(true);
notificationCallback(true);
return resource[method](data)
.then(response => this.checkConditions(response))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment