TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2015 |
Maintained by Cristian Bica.
Warning: this project is in alpha state
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.
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"
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.
Cristian Bica, [email protected]
JobKit is available under the MIT license. See the LICENSE file for more info.