JobKit 0.9.0

JobKit 0.9.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Apr 2015

Maintained by Cristian Bica.



JobKit 0.9.0

Warning: this project is in alpha state

About

JobKit is a job queueing system for iOS application. It has a pluggable storage adapters and this repo contains adapters for Core Data (persistent), Realm (persistent) and a memory adapter.

Currently it has a naive implementation for a mobile device as it checks periodically (tickInterval) for new jobs but I'm going to implement an notifications based processing trigger.

Installation

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

# this will install all the available storage adapters and their dependencies
pod "JobKit"
# this will install the core classes and the Realm adapter
pod "JobKit/Realm"
# this will install the core classes and the Core Data adapter
pod "JobKit/CoreData"
# this will install the core classes and the Memory adapter
pod "JobKit/Memory"

Usage

In your AppDelegate initialize JobKit:

  //initialize manager
  [JobKit setupDefaultManagerWithStorageProvider:[JKCoreDataAdapter class]];
  //set tick interval
  [JobKit defaultManager].tickInterval = .5;
  //start processing jobs
  [JobKit start];

There are 3 way in which you can enqueue jobs to JobKit:

1 - Creating a subclass of JKJob

@interface JKTestJob : JKJob
@end

@implementation JKTestJob
- (void)perform {
  //any arguments passed to the job can be found at self.arguments
}
@end

//enqueue a job
[JKTestJob performLater:nil];
[JKTestJob performLater:@["arg"]];
[JKTestJob performLater:@[@"arg1", @"2", @{@(3) : @"4"}]];

Important: All arguments must conform to the NSCoding protocol.

2 - Enqueue invocation of a class method for any object

[SomeClass jk_performLater:@selector(aClassMethod) arguments:nil]
[SomeClass jk_performLater:@selector(aClassMethod) arguments:@["arg"]]

Important: All arguments must conform to the NSCoding protocol.

3 - Enqueue invocation of an instance method for any object instance

[anObject jk_performLater:@selector(aClassMethod) arguments:nil]
[anObject jk_performLater:@selector(aClassMethod) arguments:@["arg"]]

Important: The object and all arguments must conform to the NSCoding protocol.

TODO

  1. Optimize triggering job processing
  2. Implement retry mechanism
  3. Query interface for jobs
  4. UI for jobs
  5. Schedule jobs in the future / with delay
  6. Process jobs on background modes

Author

Cristian Bica, [email protected]

License

JobKit is available under the MIT license. See the LICENSE file for more info.