Skip to content

Instantly share code, notes, and snippets.

@dmethvin
Created October 13, 2011 17:50
Show Gist options
  • Save dmethvin/1284922 to your computer and use it in GitHub Desktop.
Save dmethvin/1284922 to your computer and use it in GitHub Desktop.
Use of deferreds and pipe
fetchCurrentPosition()
.then(updateLocationDisplay)
.pipe(fetchWeatherAtThisLocation)
.then(updateWeatherDisplay)
.pipe(determineWeatherType)
.then(updateRecommendations)
.then(updateAppTile);
function fetchCurrentPosition()
{
return $.Deferred( function( deferred ) {
navigator.geolocation.getCurrentPosition(
deferred.resolve, deferred.reject
);
}).promise();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment