{"action":"opened","issue":{"url":"https://api.github.com/repos/feathersjs/feathers-reactive/issues/41","repository_url":"https://api.github.com/repos/feathersjs/feathers-reactive","labels_url":"https://api.github.com/repos/feathersjs/feathers-reactive/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/feathersjs/feathers-reactive/issues/41/comments","events_url":"https://api.github.com/repos/feathersjs/feathers-reactive/issues/41/events","html_url":"https://github.com/feathersjs/feathers-reactive/issues/41","id":198218740,"number":41,"title":"Impossible to type","user":{"login":"harangue","id":957238,"avatar_url":"https://avatars.githubusercontent.com/u/957238?v=3","gravatar_id":"","url":"https://api.github.com/users/harangue","html_url":"https://github.com/harangue","followers_url":"https://api.github.com/users/harangue/followers","following_url":"https://api.github.com/users/harangue/following{/other_user}","gists_url":"https://api.github.com/users/harangue/gists{/gist_id}","starred_url":"https://api.github.com/users/harangue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harangue/subscriptions","organizations_url":"https://api.github.com/users/harangue/orgs","repos_url":"https://api.github.com/users/harangue/repos","events_url":"https://api.github.com/users/harangue/events{/privacy}","received_events_url":"https://api.github.com/users/harangue/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-31T05:15:46Z","updated_at":"2016-12-31T05:15:46Z","closed_at":null,"body":"I'm still slowly (but surely) working my way through and typing some core Feathers libraries. Unfortunately, I'm at an impasse with feathers-reactive. There's just no good way to statically type a function that can return both a `Promise` and an `Observable`. At best, you treat the return type as generic, but that gets messy very quickly.\r\n\r\nWhile I was thinking of possible solutions, it occurred to me that the fact that this can't easily be described with a type system maybe means that it shouldn't be that way. Magically returning both a Promise and Observable with `promisify` is arguably not ideal from an API design standpoint.\r\n\r\nI think one possible solution would be to register a method on the service output that can transform the return type, like:\r\n```\r\nservice.find({}).toReactive().subscribe\r\n```\r\nOf course for compatibility you'd have to retain standard Promise support\r\n```\r\nservice.find({}).then()\r\n```\r\nwhich again obscures the return type a bit.\r\n\r\nAlternatively, the service method calls themselves could change, like\r\n```\r\nservice.findReactive({})\r\n```\r\nthough this is maybe a bit confusing to developers.\r\n\r\nAny thoughts on this? There's problem something better than these."}}
{"actor":{"display_login":"harangue"}}