You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry, this is going to be a noob question. I'm just learning these things, and want to put together a node module which works with docker.
And this module is awesome to use as far as I understand Promises right now, and structure of exporting object prototype functions.
So I have a DockerHelper object with the exported function pullImage which should handle, pulling an image. And than, I'm calling that function and once it finishes, I want to create a container out of that pulled image.
Now, I tried doing it with bluebird, or promises, doing the container create in the then, but it immediately jumps to that section ( which, as far as I understand, is an intended behaviour of asynchronous functions ).
So.. I kind of want to wait for that pull to finish. I found the helper followProgress which is sort of what I want. Especially the onFinish part. But that's in my function which handles the pull. And I'm creating the container in another function. Separation of concern and all that.
I also tried it with new Promise(function(resolve, reject... and than return the promise and do the then part like this:
varpull=dHelper.pullMinecraftImageVersion(version);pull.then(function(result){console.log('Done pulling.');console.log('Create container out of the pulled image with name: %s',chalk.green(config.containerName));}).catch(function(err){console.log(err);});
If I understood Promises, the then was supposed to wait? :D Maybe I misunderstood the concept described here: https://www.promisejs.org/. If I understood things correctly, promises are async by nature so you aren't supposed to wait on them. So I'm stuck with the progress helper on waiting for the pull to finish? Or is my entire design flawed here?
Thanks for the all the help folks!!! And sorry for the noobness. :)
The text was updated successfully, but these errors were encountered:
Hi!
Sorry, this is going to be a noob question. I'm just learning these things, and want to put together a node module which works with docker.
And this module is awesome to use as far as I understand Promises right now, and structure of exporting object prototype functions.
So I have a DockerHelper object with the exported function pullImage which should handle, pulling an image. And than, I'm calling that function and once it finishes, I want to create a container out of that pulled image.
Now, I tried doing it with bluebird, or promises, doing the container create in the
then
, but it immediately jumps to that section ( which, as far as I understand, is an intended behaviour of asynchronous functions ).So.. I kind of want to wait for that pull to finish. I found the helper
followProgress
which is sort of what I want. Especially the onFinish part. But that's in my function which handles the pull. And I'm creating the container in another function. Separation of concern and all that.Thus my question is, how do people do this? :D
Here is all my code as messy as it is right now: https://github.com/Skarlso/miner
This line in particular: https://github.com/Skarlso/miner/blob/master/docker.js#L23
I also tried it with
new Promise(function(resolve, reject...
and than return the promise and do thethen
part like this:If I understood Promises, the
then
was supposed to wait? :D Maybe I misunderstood the concept described here: https://www.promisejs.org/. If I understood things correctly, promises are async by nature so you aren't supposed to wait on them. So I'm stuck with the progress helper on waiting for the pull to finish? Or is my entire design flawed here?Thanks for the all the help folks!!! And sorry for the noobness. :)
The text was updated successfully, but these errors were encountered: