{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/3152","repository_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa","labels_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/3152/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/3152/comments","events_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/3152/events","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/3152","id":173342416,"number":3152,"title":"Best way to implement Promises","user":{"login":"victoraugustolls","id":7843637,"avatar_url":"https://avatars.githubusercontent.com/u/7843637?v=3","gravatar_id":"","url":"https://api.github.com/users/victoraugustolls","html_url":"https://github.com/victoraugustolls","followers_url":"https://api.github.com/users/victoraugustolls/followers","following_url":"https://api.github.com/users/victoraugustolls/following{/other_user}","gists_url":"https://api.github.com/users/victoraugustolls/gists{/gist_id}","starred_url":"https://api.github.com/users/victoraugustolls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victoraugustolls/subscriptions","organizations_url":"https://api.github.com/users/victoraugustolls/orgs","repos_url":"https://api.github.com/users/victoraugustolls/repos","events_url":"https://api.github.com/users/victoraugustolls/events{/privacy}","received_events_url":"https://api.github.com/users/victoraugustolls/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-08-26T00:31:37Z","updated_at":"2016-08-27T18:27:43Z","closed_at":null,"body":"Hi! First of all, great work with ReactiveCocoa. I just started learning it this week and enjoying it a lot. Taking a look at videos, reading documentation and etc.\r\n\r\nNow my question...\r\n\r\nI wanna substitute PromiseKit in my project for ReactiveCocoa, and for this I need to find the best way to chain async calls like I'm doing right now (something similar), example below:\r\n\r\n    LocksmithWrapper.getUserHash()\r\n        .then { hash -> Promise<JSON> in\r\n            let router = UserRouter.GetAddress(hash)\r\n            return AlamofireWrapper.perform(request: router)\r\n        }\r\n        .then { json -> Void in\r\n            let address = Address(withJson: json)\r\n            completion(Result.Success(address))\r\n        }\r\n        .always {\r\n            UIApplication.sharedApplication().networkActivityIndicatorVisible = false\r\n        }\r\n        .error { error in\r\n            completion(Result.Failure(error))\r\n        }\r\n\r\nCan anyone point me into the right direction? I'm still feeling kind of lost and think the best way was to ask here, sorry if I'm wrong! And thanks in advance!"},"comment":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/comments/242933069","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/3152#issuecomment-242933069","issue_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/3152","id":242933069,"user":{"login":"victoraugustolls","id":7843637,"avatar_url":"https://avatars.githubusercontent.com/u/7843637?v=3","gravatar_id":"","url":"https://api.github.com/users/victoraugustolls","html_url":"https://github.com/victoraugustolls","followers_url":"https://api.github.com/users/victoraugustolls/followers","following_url":"https://api.github.com/users/victoraugustolls/following{/other_user}","gists_url":"https://api.github.com/users/victoraugustolls/gists{/gist_id}","starred_url":"https://api.github.com/users/victoraugustolls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victoraugustolls/subscriptions","organizations_url":"https://api.github.com/users/victoraugustolls/orgs","repos_url":"https://api.github.com/users/victoraugustolls/repos","events_url":"https://api.github.com/users/victoraugustolls/events{/privacy}","received_events_url":"https://api.github.com/users/victoraugustolls/received_events","type":"User","site_admin":false},"created_at":"2016-08-27T18:27:43Z","updated_at":"2016-08-27T18:27:43Z","body":"If each of my calls have a different `ErrorType`, I can't `flatMap` them is this the expected behaviour?\r\n\r\nExample below:\r\n\r\n    AlamofireWrapper.generateRequest(withRouter: router)\r\n    .flatMap(.Concat) { request > SignalProducer<JSON, EncodingError>\r\n        return AlamofireWrapper.perform(request: request).ret\r\n    }\r\n    .flatMap(.Concat) { json -> SignalProducer<JSON, NSError>\r\n        hash = json[\"data\",\"hash\"].string!\r\n        let router = UserRouter.GetInfo([\"hash\":hash])\r\n        return AlamofireWrapper.perform(request: router)\r\n    }\r\n    .flatMap(.Concat) { json -> SignalProducer<Bool, ErrorType>\r\n        let user = User(withJson: json)\r\n        let account = Account(email: info.email, password: info.password, hash: hash, user: user)\r\n        return KeychainWrapper.save(user: account)\r\n    }\r\n    .on (terminated:  {\r\n            completion(Result.Success(success))\r\n        }"}}
{"actor":{"display_login":"victoraugustolls"}}