Slightly more elegant results of queries
This commit is contained in:
@@ -235,7 +235,10 @@ function (layer, dbConnection, callback) {
|
||||
// to define the queries of the second phase
|
||||
queries.phase(() => firstPhaseQueries(queries, context));
|
||||
queries.phase(() => secondPhaseQueries(queries, context));
|
||||
queries.run(results => callback(null, results)).catch(error => callback(error));
|
||||
queries.run()
|
||||
.then(results => callback(null, results))
|
||||
.catch(error => callback(error));
|
||||
|
||||
};
|
||||
|
||||
module.exports = MapnikLayerStats;
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
* }));
|
||||
* });
|
||||
* // Execute all tasks
|
||||
* p.run((results) => {
|
||||
* p.run().then((results) => {
|
||||
* console.log("RESULTS:", results);
|
||||
* }).catch((err) => {
|
||||
* console.log("ERROR:", error);
|
||||
@@ -82,14 +82,13 @@ module.exports = class PhasedExecution {
|
||||
task(promise) {
|
||||
this.tasks.push(promise);
|
||||
}
|
||||
run(callback) {
|
||||
run() {
|
||||
this.tasks = [];
|
||||
let phase = this.phases.shift();
|
||||
if (phase) {
|
||||
phase(this);
|
||||
return Promise.all(this.tasks)
|
||||
.then(() => this.run())
|
||||
.then(() => { if (callback) { callback(this.results); } });
|
||||
return Promise.all(this.tasks).then(() => this.run());
|
||||
}
|
||||
return this.results;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user