{"action":"created","issue":{"url":"https://api.github.com/repos/n1k0/casperjs/issues/1432","repository_url":"https://api.github.com/repos/n1k0/casperjs","labels_url":"https://api.github.com/repos/n1k0/casperjs/issues/1432/labels{/name}","comments_url":"https://api.github.com/repos/n1k0/casperjs/issues/1432/comments","events_url":"https://api.github.com/repos/n1k0/casperjs/issues/1432/events","html_url":"https://github.com/n1k0/casperjs/issues/1432","id":131893617,"number":1432,"title":"CasperJS Sync & Async behavious","user":{"login":"robin-obrien","id":17042319,"avatar_url":"https://avatars.githubusercontent.com/u/17042319?v=3","gravatar_id":"","url":"https://api.github.com/users/robin-obrien","html_url":"https://github.com/robin-obrien","followers_url":"https://api.github.com/users/robin-obrien/followers","following_url":"https://api.github.com/users/robin-obrien/following{/other_user}","gists_url":"https://api.github.com/users/robin-obrien/gists{/gist_id}","starred_url":"https://api.github.com/users/robin-obrien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robin-obrien/subscriptions","organizations_url":"https://api.github.com/users/robin-obrien/orgs","repos_url":"https://api.github.com/users/robin-obrien/repos","events_url":"https://api.github.com/users/robin-obrien/events{/privacy}","received_events_url":"https://api.github.com/users/robin-obrien/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/n1k0/casperjs/labels/Help%20Request","name":"Help Request","color":"eeeeee"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-02-06T20:04:34Z","updated_at":"2016-02-15T14:21:54Z","closed_at":"2016-02-13T11:25:22Z","body":"I really appreciate the work invested by the people behind CasperJS and the ideas behind it are really great. However, one thing that is almost impossible to understand is the flow and dependencies between the steps in the CasperJS (For people that are not part of the core development team). With more than 10 years of programming experience and 7 days working with CasperJS, I have not found documentation explaining how to create any sort of dependency between steps and how to achieve having steps synchronously. I invested many hours of trial and error. Regardless the trial and error, and just from the logic I implemented, Eeventually, my code had so many asyc blocks and scopes that it became not determinant without having something to orchestrate it.\r\n\r\nHow can I create achieve dependency between steps?"},"comment":{"url":"https://api.github.com/repos/n1k0/casperjs/issues/comments/184226890","html_url":"https://github.com/n1k0/casperjs/issues/1432#issuecomment-184226890","issue_url":"https://api.github.com/repos/n1k0/casperjs/issues/1432","id":184226890,"user":{"login":"jefleponot","id":5547697,"avatar_url":"https://avatars.githubusercontent.com/u/5547697?v=3","gravatar_id":"","url":"https://api.github.com/users/jefleponot","html_url":"https://github.com/jefleponot","followers_url":"https://api.github.com/users/jefleponot/followers","following_url":"https://api.github.com/users/jefleponot/following{/other_user}","gists_url":"https://api.github.com/users/jefleponot/gists{/gist_id}","starred_url":"https://api.github.com/users/jefleponot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jefleponot/subscriptions","organizations_url":"https://api.github.com/users/jefleponot/orgs","repos_url":"https://api.github.com/users/jefleponot/repos","events_url":"https://api.github.com/users/jefleponot/events{/privacy}","received_events_url":"https://api.github.com/users/jefleponot/received_events","type":"User","site_admin":false},"created_at":"2016-02-15T14:21:54Z","updated_at":"2016-02-15T14:21:54Z","body":"Hi @robin-obrien,\r\n\r\nHere is a copy paste oh our main loop.\r\nI hope it will help you.\r\n```\r\n/**\r\n * Run casper navigation if exists\r\n *\r\n * @param  Function  fct     OnCompleted function \r\n */\r\nScenarioClass.prototype.run = function runScenario(fct){\r\n  \"use strict\";\r\n  var scenario = this;\r\n\r\n  this.casper.start().then(function(){\r\n        scenario.start();\r\n  });\r\n\r\n  // inscription du scenario      \r\n  this.steps.forEach(function(elm,idx){\r\n    scenario.casper.then(function nextStep(){\r\n      scenario.isRunnig = true;\r\n      scenario.currentStep = idx;\r\n      for (var i=0, l=scenario.stepCallBacks.length;i<l;i++) {\r\n        scenario.stepCallBacks[i].call(scenario.casper, elm, idx);\r\n      }\r\n      return true;\r\n    });\r\n  });\r\n\r\n  // inscription des exports\r\n  this.casper.run(function(){\r\n    scenario.stop();\r\n    scenario.complete();\r\n  });\r\n};\r\n\r\n```\r\n\r\n\r\n"}}