This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A recursive function returning Observable<number> | |
function recurseToZero(n) { | |
console.log('B. Entering recursive function for [' + n + '].'); | |
// Once we hit zero, bail out of the recursion. The key to recursion is that | |
// it stops at some point, and the callstack can be "rolled" back up. | |
if (n === 0) { | |
return Rx.Observable.of(0); | |
} | |
// Start a NEW PROMISE CHAIN that will become the continuation of the parent | |
// promise chain. This new promise chain now becomes a completely tangential |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A recursive function returning Promise<number> | |
function recurseToZero(n) { | |
console.log('B. Entering recursive function for [' + n + '].'); | |
// Once we hit zero, bail out of the recursion. The key to recursion is that | |
// it stops at some point, and the callstack can be "rolled" back up. | |
if (n === 0) { | |
// We could just return 0 but we do return Promise.resolve to have a consistent return type | |
return Promise.resolve(0); | |
} | |
// Start a NEW PROMISE CHAIN that will become the continuation of the parent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From: http://www.joshmorony.com/store-camera-photos-permanently-using-phonegap-ionic-ngcordova/ | |
$cordovaCamera.getPicture(options).then(function(imagePath){ | |
//Grab the file name of the photo in the temporary directory | |
var currentName = imagePath.replace(/^.*[\\\/]/, ''); | |
//Create a new name for the photo | |
var d = new Date(), | |
n = d.getTime(), | |
newFileName = n + ".jpg"; |