Skip to content

Commit

Permalink
Fix when.defer() usage
Browse files Browse the repository at this point in the history
It turns out that there are a bunch of places in our code where we
use `when.defer()` and return the deferred instance instead of its
`promise` property.  This works in most cases because when's deferred
promises are thenable, however they don't have all of when's API, like
`always`.  This change makes sure we correctly return `deferred.promise`
everywhere.

It's probably a quirk of the version of when we are using
that defers aren't always-able and always isn't part of the A+ spec,
so there's no reason to add additional tests for these.
  • Loading branch information
mramato committed Oct 30, 2015
1 parent c063697 commit c8d4fbd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Source/DataSources/KmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ define([
deferred.reject(reader.error);
});
reader.readAsArrayBuffer(magicBlob);
return deferred;
return deferred.promise;
}

function readBlobAsText(blob) {
Expand All @@ -216,7 +216,7 @@ define([
deferred.reject(reader.error);
});
reader.readAsText(blob);
return deferred;
return deferred.promise;
}

function loadXmlFromZip(reader, entry, uriResolver, deferred) {
Expand Down Expand Up @@ -1644,7 +1644,7 @@ define([
deferred.reject(e);
});

return deferred;
return deferred.promise;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/GroundPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ define([
*/
readyPromise : {
get : function() {
return this._readyPromise;
return this._readyPromise.promise;
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ define([
*/
readyPromise : {
get : function() {
return this._readyPromise;
return this._readyPromise.promise;
}
},

Expand Down Expand Up @@ -3103,7 +3103,7 @@ define([
var model = this;
frameState.afterRender.push(function() {
model._ready = true;
model.readyPromise.resolve(model);
model._readyPromise.resolve(model);
});
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Primitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ define([
*/
readyPromise : {
get : function() {
return this._readyPromise;
return this._readyPromise.promise;
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion Source/Widgets/Viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to
}
});

return zoomPromise;
return zoomPromise.promise;
}

function clearZoom(viewer) {
Expand Down

0 comments on commit c8d4fbd

Please sign in to comment.