Skip to content

Instantly share code, notes, and snippets.

@matzew
Created March 14, 2013 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matzew/04f069dfbed2cc77a8b4 to your computer and use it in GitHub Desktop.
Save matzew/04f069dfbed2cc77a8b4 to your computer and use it in GitHub Desktop.

I suggest we need some more enhanced filter/read function:

(E.g. with a resource argument to receive the nested resource...)

NSURL* serverURL = [NSURL URLWithString:@"http://todo-aerogear.rhcloud.com/"];

AGPipeline* pipeline = [AGPipeline pipelineWithBaseURL:serverURL];

// Add a REST pipe for the 'posts' endpoint
id<AGPipe> postsPipe = [pipeline pipe:^(id<AGPipeConfig> config) {
    [config setName:@"posts"];
}];



// READ comments for ID:1 

[postsPipe read:1 resource:@"comments" success:^(id responseObject) {
    // LOG the JSON response, returned from the server:
    NSLog(@"READ RESPONSE\n%@", [responseObject description]);
} failure:^(NSError *error) {
    // when an error occurs... at least log it to the console..
    NSLog(@"Read: An error occured! \n%@", error);
}];


// READ comments for ID:2 

[postsPipe read:2 resource:@"comments" success:^(id responseObject) {
    // LOG the JSON response, returned from the server:
    NSLog(@"READ RESPONSE\n%@", [responseObject description]);
} failure:^(NSError *error) {
    // when an error occurs... at least log it to the console..
    NSLog(@"Read: An error occured! \n%@", error);
}];

Here... we can REUSE the pipe, to receive different comments, from different posts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment