Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I created a light-weight solution for this. It's called Sequencer and it's up on <a href="https://github.com/berzniz/Sequencer" rel="noreferrer">github</a>.</p> <p>It makes chaining API calls (or any other async code) easy and straightforward.</p> <p>Here's an example of using AFNetworking with it:</p> <pre><code>Sequencer *sequencer = [[Sequencer alloc] init]; [sequencer enqueueStep:^(id result, SequencerCompletion completion) { NSURL *url = [NSURL URLWithString:@"https://alpha-api.app.net/stream/0/posts/stream/global"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { completion(JSON); } failure:nil]; [operation start]; }]; [sequencer enqueueStep:^(NSDictionary *feed, SequencerCompletion completion) { NSArray *data = [feed objectForKey:@"data"]; NSDictionary *lastFeedItem = [data lastObject]; NSString *cononicalURL = [lastFeedItem objectForKey:@"canonical_url"]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:cononicalURL]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { completion(responseObject); } failure:nil]; [operation start]; }]; [sequencer enqueueStep:^(NSData *htmlData, SequencerCompletion completion) { NSString *html = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding]; NSLog(@"HTML Page: %@", html); completion(nil); }]; [sequencer run]; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload