MKNetworkKit icon indicating copy to clipboard operation
MKNetworkKit copied to clipboard

[Enhancement] Enqueue dependencies of MKNetworkOperation

Open guoyk93 opened this issue 10 years ago • 0 comments

In my own business logic, I wish to chain multiple MKNetworkOperations. For example, upload a file, get the file_id of uploaded files then put it into post field of the next operation. I make this with subclassing MKNetworkEngine as follow.

- (void)enqueueOperation:(MKNetworkOperation *)request forceReload:(BOOL)forceReload
{
  [request.dependencies enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
    if ([obj isKindOfClass:[MKNetworkOperation class]]) {
      [self enqueueOperation:obj forceReload:forceReload];
    }
  }];

  [super enqueueOperation:request forceReload:forceReload];
}

I also insert a subclassable method in the -(void) main of MKNetworkOpeartion so I have the chance to modify the post filed before it start.

Because I'm not a experienced library developer, instead of sending a pull request, I wish you could add some kind of mechanism like that.

Best wishes.

guoyk93 avatar May 04 '14 15:05 guoyk93