当前位置:网站首页>Link multiple alamofire requests - chain multiple alamofire requests
Link multiple alamofire requests - chain multiple alamofire requests
2022-06-10 16:31:00 【Saffron】
problem :
I'm looking for a good pattern with which I can chain multiple HTTP requests. I am looking for a way to link multiple HTTP Good mode of request .I want to use Swift, and preferrably Alamofire . I want to use Swift, It is best to Alamofire .
Say, for example, I want to do the following: for instance , I want to do the following :
- Make a PUT request issue PUT request
- Make a GET request issue GET request
- Reload table with data Reload table with data
It seems that the concept of promises may be a good fit for this. It seems , The concept Commitment It may be a perfect fit for this .PromiseKit could be a good option if I could do something like this: If I could do something like this , PromiseKit It might be a good choice :
NSURLConnection.promise( Alamofire.request( Router.Put(url: "http://httbin.org/put") )).then { (request, response, data, error) in Alamofire.request( Router.Get(url: "http://httbin.org/get") ) }.then { (request, response, data, error) in // Process data}.then { () -> () in // Reload table}but that's not possible or at least I'm not aware of it. But it's impossible , Or at least I don't know .
How can I achieve this functionality without nesting multiple methods? How to implement this function without nesting multiple methods ?
I'm new to iOS so maybe there's something more fundamental that I'm missing. I am a iOS Novice , So maybe I lack something more basic .What I've done in other frameworks such as Android is to perform these operations in a background process and make the requests synchronous. I am here Android What other frameworks do is perform these operations in the background process and synchronize the requests .But Alamofire is inherently asynchronous , so that pattern is not an option. however Alamofire It's asynchronous in nature , So this model is not an option .
Solution :
Reference resources : https://stackoom.com/en/question/1w9Gl边栏推荐
- AI video cloud: a good wife in the era of we media
- 袋鼠云数栈基于CBO在Spark SQL优化上的探索
- Application of stop in screen program_ SAP LIUMENG_
- Diagram of the quarterly report of station B: the revenue is RMB 5.1 billion, with a year-on-year increase of 30% and nearly 300million monthly active users
- PV operation daily question 1 - single wooden bridge problem (variant 2)
- C # homework - student information management system
- MapReduce案例之排序
- The fragrant locust flowers on the fragrant locust road have been in a hurry for four years.
- 数字图像处理:灰度化
- MapReduce之分区案例的代码实现
猜你喜欢

Digital image processing: graying

硬件仪器的使用

Duyuan outdoor sprint to Shenzhen Stock Exchange: the annual revenue is 350million, and the color of Lin Xizhen family is obvious

Weilai quarterly report diagram: the revenue was 9.9 billion yuan, a year-on-year increase of 24%, and the operating loss was nearly 2.2 billion yuan

Diagram of the quarterly report of station B: the revenue is RMB 5.1 billion, with a year-on-year increase of 30% and nearly 300million monthly active users

Actual combat of software testing e-commerce project (actual combat video station B has been released)
![[MySQL basics]](/img/fc/48e9c6b739e29472a7a103e47663af.png)
[MySQL basics]
![leetcode:730. Statistics of different palindrome subsequences [traversed by point and surface interval DP + 3D DP + diagonal]](/img/90/79c51f944709ef230f394e874aa9ac.png)
leetcode:730. Statistics of different palindrome subsequences [traversed by point and surface interval DP + 3D DP + diagonal]

Middle office: Data middle office, business middle office, technology middle office, application middle office, AI middle office

Save a window with a specific size, resolution, or background color
随机推荐
What are the pitfalls of redis's current network: using a cache and paying for disk failures?
Aggregate sum of MapReduce cases
Join operation cases in the map phase of MapReduce
安霸CV2FS/CV22FS获得ASIL C芯片功能安全认证,超越市场同类芯片水平
China coal machinery industry development research and investment prospect analysis report 2022-2028 Edition
Devops-1- introduction
Devops software architecture evolution
PHP wechat H5 payment demo
服务器运维环境安全体系(下篇)
2D human posture estimation for posture estimation - associated embedding: end to end learning for joint detection and grouping
Devops-2- from the Phoenix Project
leetcode:730. 统计不同回文子序列【由点及面区间dp + 三维dp + 对角线遍历】
Diagram of the quarterly report of station B: the revenue is RMB 5.1 billion, with a year-on-year increase of 30% and nearly 300million monthly active users
PV operation daily question - Restaurant Service
Come with me to understand gaussdb (for opengauss) [Gauss is not a mathematician this time]
C # game prototype character map dual movement
leetcode:730. Statistics of different palindrome subsequences [traversed by point and surface interval DP + 3D DP + diagonal]
2D human posture estimation for posture estimation - numerical coordinate progression with revolutionary neural networks (dsnt)
Smart home (3) competitive product analysis of Intelligent Interaction
Online document collaboration tool is the first step to improve work efficiency
