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

Changes after review

parent 9f7c19b3
...@@ -8,10 +8,10 @@ import httpStatusCodes from './http_status'; ...@@ -8,10 +8,10 @@ import httpStatusCodes from './http_status';
* new Poll({ * new Poll({
* resource: resource, * resource: resource,
* method: 'name', * method: 'name',
* data: {page: 1, scope: 'all'}, * data: {page: 1, scope: 'all'}, // optional
* successCallback: () => {}, * successCallback: () => {},
* errorCallback: () => {}, * errorCallback: () => {},
* auxiliarCallback: () => {}, * notificationCallback: () => {}, // optional
* }).makeRequest(); * }).makeRequest();
* *
* Usage in pipelines table with visibility lib: * Usage in pipelines table with visibility lib:
...@@ -22,7 +22,7 @@ import httpStatusCodes from './http_status'; ...@@ -22,7 +22,7 @@ import httpStatusCodes from './http_status';
* data: { page: pageNumber, scope }, * data: { page: pageNumber, scope },
* successCallback: this.successCallback, * successCallback: this.successCallback,
* errorCallback: this.errorCallback, * errorCallback: this.errorCallback,
* auxiliarCallback: this.updateLoading, * notificationCallback: this.updateLoading,
* }); * });
* *
* if (!Visibility.hidden()) { * if (!Visibility.hidden()) {
...@@ -48,6 +48,8 @@ export default class Poll { ...@@ -48,6 +48,8 @@ export default class Poll {
constructor(options = {}) { constructor(options = {}) {
this.options = options; this.options = options;
this.options.data = options.data || {}; this.options.data = options.data || {};
this.options.notificationCallback = options.notificationCallback ||
function notificationCallback() {};
this.intervalHeader = 'POLL-INTERVAL'; this.intervalHeader = 'POLL-INTERVAL';
this.timeoutID = null; this.timeoutID = null;
...@@ -68,10 +70,10 @@ export default class Poll { ...@@ -68,10 +70,10 @@ export default class Poll {
} }
makeRequest() { 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. // It's called everytime a new request is made. Useful to update the status.
auxiliarCallback(true); notificationCallback(true);
return resource[method](data) return resource[method](data)
.then(response => this.checkConditions(response)) .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