title: Alamofire - best way of retry offline request
body: <p>Here is what I need:</p>
  
  <ol>
  <li>call post api</li>
  <li>if success: do nothing</li>
  <li>if failed(no internet available): put the request on to a stack</li>
  <li>monitor if the network has come back</li>
  <li>if network available: retry everything on that stack</li>
  </ol>
  
  <p>even if the user close the app, I still need to have the stack available. I need to store the stack onto the disk</p>
  
  <p>Here's what I plan to do:</p>
  
  <ol>
  <li>have a class called apiRequest, it contains
  
  <ol>
  <li>parameters</li>
  <li>url</li>
  </ol></li>
  <li>have a class called apiRequestManager, it contains
  
  <ol>
  <li>array of apiRequest</li>
  </ol></li>
  </ol>
  
  <p>the apiRequest array is stored onto the disk. Every time, when user want to call the api, I call Alamofire.request first and if failed, put it onto the apiRequest array. </p>
  
  <p>use NetworkReachabilityManager to listen if user can reach the server. If true, then retry everything in apiRequest. Everytime a request succeed, remove it from the array. else keep it as is. </p>
  
  <p>The reason I ask this question is because I am new to the Alamofire framework. I don't know if this is a good way to go or if this case is already been handled in Alamofire.</p>
  
  <p>Also, there is a RequestRetrier protocol. But I don't want to retry every single request again and again, I want to retry it all at the same time and if not succeed I do want to store the request on to the disk for future retry so I guess that is not what I want to use? </p>
  
  <p>Any suggestions?</p>
  
  <p>Thanks.</p>