These are chat archives for rosshinkley/nightmare

Dec 2016
Dec 05 2016 15:17
@Siilwyn Not 100% sure but I think within the respondTo callback, instead of just returning the position, you would want to call done with the position as the second argument (the first argument being null or an error if appropriate). Here's an example of it being used within nightmare for responding to javascript:
Dec 05 2016 19:42
@johnferro alright thanks going to try that right now!
Dec 05 2016 19:48
Woo thanks!
It works! :sparkles:
    function (name, options, parent, win, renderer, done) {
        parent.respondTo('getWindowPosition', function (done) {
            parent.emit('log', `Window position: ${win.getPosition()}`);
            done(null, win.getPosition());
    function (done) {'getWindowPosition', done);
Anybody knows a conciser way to write this? The second done call seems a bit weird to me`.
Dec 05 2016 21:15
By the second done you mean the one outside of the parent.respondTo scope? Here might be a good place to get started looking at what nightmare is doing under the hood to register the action: From my understanding (take with a grain of salt) since nightmare and electron are running in separate processes, nightmare needs to queue the registering of the action itself with the electron process. The second done is what let's nightmare know that this registration is complete. The first done (within the parent.respondTo) on the other hand is electron triggering a callback to send its response (in this case to a 'getWindowPosition' command) back to the node/nightmare process. So that first done callback is actually being called every time a 'getWindowPosition' command while the second done is only being called when the action first gets registered.
Dec 05 2016 21:25
oh that makes sense, thank you again so much @johnferro
appreciate it