UNPKG

terriajs

Version:

Geospatial data visualization platform.

27 lines (22 loc) 957 B
'use strict'; /*global require*/ var defined = require('terriajs-cesium/Source/Core/defined'); /** * Extends a catalog member's `load` method with another, potentially asynchronous. * load function. The catalog member will not be fully loaded until both the original * and the new load return and their promises resolve. * @param {CatalogMember} catalogMember The catalog member for which to extend the loading process. * @param {Function} f The additional load function. This function will be called with `this` set to the `catalogMember`. */ var extendLoad = function(catalogMember, f) { var originalLoad = catalogMember._load; catalogMember._load = function() { var originalResult = originalLoad.call(this); if (defined(originalResult)) { return originalResult.then(f.bind(this)); } else { return f.call(this); } }; }; module.exports = extendLoad;