{"action":"opened","issue":{"url":"https://api.github.com/repos/alexeypetrushin/synchronize/issues/35","labels_url":"https://api.github.com/repos/alexeypetrushin/synchronize/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/alexeypetrushin/synchronize/issues/35/comments","events_url":"https://api.github.com/repos/alexeypetrushin/synchronize/issues/35/events","html_url":"https://github.com/alexeypetrushin/synchronize/issues/35","id":104841114,"number":35,"title":"Example use of synchronize using asynchronous promises","user":{"login":"davidemiceli","id":6568243,"avatar_url":"https://avatars.githubusercontent.com/u/6568243?v=3","gravatar_id":"","url":"https://api.github.com/users/davidemiceli","html_url":"https://github.com/davidemiceli","followers_url":"https://api.github.com/users/davidemiceli/followers","following_url":"https://api.github.com/users/davidemiceli/following{/other_user}","gists_url":"https://api.github.com/users/davidemiceli/gists{/gist_id}","starred_url":"https://api.github.com/users/davidemiceli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidemiceli/subscriptions","organizations_url":"https://api.github.com/users/davidemiceli/orgs","repos_url":"https://api.github.com/users/davidemiceli/repos","events_url":"https://api.github.com/users/davidemiceli/events{/privacy}","received_events_url":"https://api.github.com/users/davidemiceli/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-04T07:15:57Z","updated_at":"2015-09-04T07:15:57Z","closed_at":null,"body":"Hi, how should synchronize work with asynchronous functions that have promises?\r\n\r\nFor example, the following case:\r\n\r\n```javascript\r\nvar sync = require('synchronize');\r\nvar knex = require('knex');\r\n\r\nvar knex = require('knex')({\r\n    client:     \"mysql\",\r\n    connection: {\r\n      host:     \"localhost\",\r\n      user:     \"root\",\r\n      password: \"mypassword\",\r\n      charset:  \"utf8\",\r\n      database: \"mydb\"\r\n    },\r\n    pool:       {\r\n      \"min\": 0,\r\n      \"max\": 7\r\n    }\r\n });\r\n\r\ndata = sync.await(\r\n\t//fs.readFile(fname, sync.defer())\r\n\tknex.raw('select ?', [1]).catch(function(err) {\r\n\t\tconsole.log(err);\r\n\t}).then(function(resp) {\r\n\t\tconsole.log(resp);\r\n\t});\r\n\t\r\n);\r\nconsole.log('Start', data);\r\n\r\nconsole.log('Fine');\r\n```\r\nFor example, in this case, where should I put sync.defer()? How should the code work? Could you help me?\r\n\r\nThanks a lot!\r\n"}}