{"action":"created","issue":{"url":"https://api.github.com/repos/casetext/fireproof/issues/12","labels_url":"https://api.github.com/repos/casetext/fireproof/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/casetext/fireproof/issues/12/comments","events_url":"https://api.github.com/repos/casetext/fireproof/issues/12/events","html_url":"https://github.com/casetext/fireproof/issues/12","id":115623937,"number":12,"title":"Should fireproof resolve on `then`?","user":{"login":"pschuegr","id":263504,"avatar_url":"https://avatars.githubusercontent.com/u/263504?v=3","gravatar_id":"","url":"https://api.github.com/users/pschuegr","html_url":"https://github.com/pschuegr","followers_url":"https://api.github.com/users/pschuegr/followers","following_url":"https://api.github.com/users/pschuegr/following{/other_user}","gists_url":"https://api.github.com/users/pschuegr/gists{/gist_id}","starred_url":"https://api.github.com/users/pschuegr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pschuegr/subscriptions","organizations_url":"https://api.github.com/users/pschuegr/orgs","repos_url":"https://api.github.com/users/pschuegr/repos","events_url":"https://api.github.com/users/pschuegr/events{/privacy}","received_events_url":"https://api.github.com/users/pschuegr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/casetext/fireproof/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-11-07T01:50:02Z","updated_at":"2015-11-13T21:32:07Z","closed_at":null,"body":"First of all, thanks for this library, very nice.\r\n\r\nA question:  I have a function call that returns a promise which I resolve with a Fireproof, which I then plan to use to run a `on('child_added')` query or something similar.  However, returning the Fireproof as part of a promise chain means that the `.then` of the Fireproof object gets called, and I end up with a snapshot instead:\r\n\r\n````\r\nfunction getFireproof() {\r\n  return doSomething()\r\n    .then(() => {\r\n      return new Fireproof(new Firebase('firebase.io/whatever'));\r\n    });\r\n}\r\n\r\ngetFireproof()\r\n  .on('child_added')  //explodes here because it's getting a snapshot val back\r\n  .then(doSomething);\r\n````\r\n\r\nIs there a nicer way to do this that I'm missing in the API?  I can get around it by hacking out the `.then` from the Fireproof instance, but that's not ideal."},"comment":{"url":"https://api.github.com/repos/casetext/fireproof/issues/comments/156561762","html_url":"https://github.com/casetext/fireproof/issues/12#issuecomment-156561762","issue_url":"https://api.github.com/repos/casetext/fireproof/issues/12","id":156561762,"user":{"login":"daguej","id":354349,"avatar_url":"https://avatars.githubusercontent.com/u/354349?v=3","gravatar_id":"","url":"https://api.github.com/users/daguej","html_url":"https://github.com/daguej","followers_url":"https://api.github.com/users/daguej/followers","following_url":"https://api.github.com/users/daguej/following{/other_user}","gists_url":"https://api.github.com/users/daguej/gists{/gist_id}","starred_url":"https://api.github.com/users/daguej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daguej/subscriptions","organizations_url":"https://api.github.com/users/daguej/orgs","repos_url":"https://api.github.com/users/daguej/repos","events_url":"https://api.github.com/users/daguej/events{/privacy}","received_events_url":"https://api.github.com/users/daguej/received_events","type":"User","site_admin":false},"created_at":"2015-11-13T21:32:07Z","updated_at":"2015-11-13T21:32:07Z","body":"If you need to return the Fireproof itself, it needs to be wrapped in something that's not a promise.\r\n\r\n```\r\nfunction getFireproof() {\r\n  return doSomething()\r\n    .then(() => {\r\n      return {\r\n        ref: new Fireproof(new Firebase('firebase.io/whatever'))\r\n      };\r\n    });\r\n}\r\n\r\ngetFireproof().then(function(result) {\r\n  result.ref.on('child_added', function() {});\r\n});\r\n```"}}