Latest 0.0.9
Homepage https://github.com/littlstar/Batch
License MIT
Authors

LSBatch control flow for Objective-C

Installation

LSBatch is available through CocoaPods. To install it,
simply add the following line to your Podfile:

pod "LSBatch"

LSBatch is also available through clibs.
To install it, simply run:

$ clib install littlstar/LSBatch

or add it to your package.json file:

...
  "dependencies": {
    "littlstar/LSBatch": "*"
  }
...

Usage

LSBatch provides mechanisms for adding block control flow and invoking
them with a set concurrency. LSBatch supports a delegate pattern as well.

Using LSBatch is as simple as providing a block for work to be done. The
block is a type defined with the following typedef:

typedef void (^LSBatchWorkerCallback)(LSBatchNextCallback);

Where LSBatchNextCallback is the callback block that should be called
when work is complete for the "worker block". It is a type defined with
the following typedef:

typedef void (^LSBatchNextCallback)(id <NSObject> err);

You can provide a callback block that is executed when all work is
complete. The block is a type defined with the following typedef:

typedef void (^LSBatchDoneCallback)(id <NSObject> err);

A simple worker example can constructed as such:

LSBatch *batch = [LSBatch new: INFINITY];

// queue work
[batch push: ^(LSBatchNextCallback next) {
  // do work here
  next(nil);
}];

// more work
[batch push: ^(LSBatchNextCallback next) {
  // more work here
  next(nil);
}];

// Execute worker blocks calling the provided
// callback block.
[batch end: ^(NSError *err) {
  if (err) {
    // handle error
  } else {
    // handle success
  }
}];

Delegates

LSBatch defines the following LSBatchDelegate protocol:

@protocol LSBatchDelegate <NSObject>

// Called when batch did finish all work.
- (void) batchDidFinish: (id <LSBatch>) batch;

// Called when batch encountered an error.
- (void) batch: (id <LSBatch>) batch didFailWithError: (id <NSObject>) err;

// Called when batch work has been aborted.
- (void) batchDidAbort: (id <LSBatch>) batch;
@end

Documentation

Coming soon…

License

MIT

Latest podspec

{
    "name": "LSBatch",
    "version": "0.0.9",
    "summary": "Batch control flow for Objective-C",
    "description": "                   Control flow can be tough and GCD provides a great abstraction.n                   However, Batch aims to make this much easier through callbackn                   blocks and delegate method patterns.nn",
    "homepage": "https://github.com/littlstar/Batch",
    "license": "MIT",
    "authors": {
        "Joseph Werle": "[email protected]"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/littlstar/Batch.git",
        "tag": "0.0.9"
    },
    "source_files": "src/*.m",
    "public_header_files": "include/*/*.h",
    "preserve_paths": "include/*/*.h"
}

Pin It on Pinterest

Share This