Replies: 5 comments
-
func callService(completionHandler: @escaping (Result<UserModel>) -> Void) {
SandboxService.createsandboxUser().then { userModel in
firstly {
SandboxService.initializeClient(publicKey: self.keyPairs.publicKey)
}.then { initModel in
SandboxService.deviceServerServiceCaller(authKey: initModel.token.token, apiKey: userModel.apiKey,privaKey: self.keyPairs.privateKey).map{ ($0, initiModel) }
}.then { serverResponseModel, initModel in
SandboxService.sessionServiceCaller(authKey: initModel.token.token, apiKey: userModel.apiKey, privaKey: self.keyPairs.privateKey)
}
}.pipe(to: completionHandler)
} |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Can you please show me how can I call a function eg; |
Beta Was this translation helpful? Give feedback.
-
…Just call it? I don’t really understand the question.
Add a catch, but it doesn’t seem like you want to do that, doesn’t the |
Beta Was this translation helpful? Give feedback.
-
|
When I write; I needed to write what I should return in For second question; I want to change completion handler return type to void and call delegate functions instead. Therefore, I need to change it to Done and Catch blocks. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm calling three services in a row. When I'm calling third service, I need to use variable from first service response which is userModel. I can get second service response which is initModel but can't reach first model userModel. My Question is that how can I use userModel in done block by returning it then blocks?
P.S: I tried to
return -> Promise<(UserModel,InstallationModel)>in first call but because UserModel is already an object not a promise, I need to convert it to promise to return it. This looks like me a bad way to do it.As you can see I'm storing it with
self.userModel = userModelwhich I don't wanna do.Beta Was this translation helpful? Give feedback.
All reactions