Created
October 12, 2018 03:03
-
-
Save lozadaOmr/79c39213cb7bb913fda22f9a16641aaa to your computer and use it in GitHub Desktop.
new Promise resolve()
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
'use strict' | |
global.Promise = require('bluebird') | |
let countStream = function () { | |
console.log('counting streams..') | |
return Promise.resolve(Math.floor(Math.random() * 2)) | |
} | |
let countInvSync = function () { | |
console.log('counting inv syncs..') | |
return Promise.resolve(Math.floor(Math.random() * 2)) | |
} | |
let fnB = function () { | |
return new Promise(resolve => { | |
countStream().then(strmCount => { | |
console.log('stream count:', strmCount) | |
if (strmCount === 0) return resolve() | |
return Promise.resolve() | |
}).then(() => { | |
return countInvSync().then(syncCount => { | |
console.log('invSync count:', syncCount) | |
if (syncCount === 0) return resolve() | |
return Promise.resolve() | |
}) | |
}).then(() => { | |
console.log('doing core stuff here..') | |
return resolve() | |
}) | |
}) | |
} | |
fnB().then(() => { | |
console.log('function fnB() done!') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment