Exposing GAPIPromise
After 0.11 GAPIPromise
become private, and I want to point to one case where it was useful.
Some actions make sense only when _mutant is already initialized, and we have spawned
event to track this.
But it is not enough, so we may begin to code such ugly code:
if (layer._mutant) {
// perform some actions
} else {
layer.on("spawned", function (){
// perform the same actions (deferred)
});
}
To avoid such constructions Leaflet has Map.whenReady
method:
https://github.com/Leaflet/Leaflet/blob/7db94fd1ec23f0967dd8b07a5e2e2b1554b6d8db/src/map/Map.js#L1459