Skip to content

Commit

Permalink
fix(HttpDataSetReader): Fix promise usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Jan 5, 2018
1 parent 35eb158 commit 68bb629
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Sources/IO/Core/HttpDataSetReader/index.js
Expand Up @@ -88,7 +88,7 @@ function processDataSet(

// Fetch geometry arrays
const pendingPromises = [];
const progressCallback = model.progressCallback;
const { progressCallback } = model;
const compression = model.fetchGzip ? 'gz' : null;
GEOMETRY_ARRAYS[dataset.vtkClass](dataset).forEach((array) => {
pendingPromises.push(fetchArray(array, { compression, progressCallback }));
Expand Down Expand Up @@ -165,15 +165,15 @@ function vtkHttpDataSetReader(publicAPI, model) {
loadData
);
},
(xhr, e) => {
reject(xhr, e);
(error) => {
reject(error);
}
);
},
});
},
(xhr, e) => {
reject(xhr, e);
(error) => {
reject(error);
}
);
});
Expand All @@ -192,8 +192,8 @@ function vtkHttpDataSetReader(publicAPI, model) {
loadData
);
},
(xhr, e) => {
reject(xhr, e);
(error) => {
reject(error);
}
);
});
Expand Down Expand Up @@ -228,13 +228,13 @@ function vtkHttpDataSetReader(publicAPI, model) {
.map((array) => array.array);

return new Promise((resolve, reject) => {
const error = (xhr, e) => {
reject(xhr, e);
const error = (e) => {
reject(e);
};

const processNext = () => {
if (arrayToFecth.length) {
const progressCallback = model.progressCallback;
const { progressCallback } = model;
const compression = model.fetchGzip ? 'gz' : null;
fetchArray(arrayToFecth.pop(), {
compression,
Expand Down Expand Up @@ -316,6 +316,11 @@ export function extend(publicAPI, model, initialValues = {}) {

// Object methods
vtkHttpDataSetReader(publicAPI, model);

// Make sure we can destructuring progressCallback from model
if (model.progressCallback === undefined) {
model.progressCallback = null;
}
}

// ----------------------------------------------------------------------------
Expand Down

0 comments on commit 68bb629

Please sign in to comment.