Latest 0.9.0
Homepage https://github.com/cristianbica/JobKit
License MIT
Platforms ios 7.0, requires ARC
Authors

CI Status
Version
License
Platform

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

@interface SomeClass : NSObject
+ (void)aClassMethod;
+ (void)aClassMethodWithAnArgument:(id)arg1 andAnother:(id)arg2;
@end
[SomeClass jk_performLater:@selector(aClassMethod) arguments:nil]
[SomeClass jk_performLater:@selector(aClassMethodWithAnArgument:andAnother:) arguments:@["arg", @(2)]]

Important: All arguments must conform to the NSCoding protocol.

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

@interface SomeClass : NSObject
- (void)aClassMethod;
- (void)aClassMethodWithAnArgument:(id)arg1 andAnother:(id)arg2;
@end
[[SomeClass new] jk_performLater:@selector(aClassMethod) arguments:nil]
[[SomeClass new] jk_performLater:@selector(aClassMethodWithAnArgument:andAnother:) arguments:@["arg", @(2)]]

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.

Latest podspec

{
    "name": "JobKit",
    "version": "0.9.0",
    "summary": "Pesistent job queueing for iOS.",
    "description": "                       Pesistent job queueing for iOS. Backed by Realm buy you can roll your own.n",
    "homepage": "https://github.com/cristianbica/JobKit",
    "license": "MIT",
    "authors": {
        "Cristian Bica": "[email protected]"
    },
    "source": {
        "git": "https://github.com/cristianbica/JobKit.git",
        "tag": "0.9.0"
    },
    "social_media_url": "https://twitter.com/cristianbica",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "default_subspecs": "All",
    "subspecs": [
        {
            "name": "All",
            "source_files": "JobKit/**/*.{h,m}",
            "public_header_files": "JobKit/**/*.h",
            "resources": "JobKit/Adapters/CoreDataAdapter/*.{xcdatamodeld,xcdatamodel}",
            "dependencies": {
                "Realm": []
            },
            "frameworks": "CoreData"
        },
        {
            "name": "Core",
            "source_files": "JobKit/{Core,Jobs,Worker}/*.{h,m}"
        },
        {
            "name": "Realm",
            "source_files": "JobKit/Adapters/RealmAdapter/*.{h,m}",
            "dependencies": {
                "Realm": [],
                "JobKit/Core": []
            }
        },
        {
            "name": "Memory",
            "source_files": "JobKit/Adapters/MemoryAdapter/*.{h,m}",
            "dependencies": {
                "JobKit/Core": []
            }
        },
        {
            "name": "CoreData",
            "resources": "JobKit/Adapters/CoreDataAdapter/*.{xcdatamodeld,xcdatamodel}",
            "source_files": "JobKit/Adapters/CoreDataAdapter/*.{h,m}",
            "frameworks": "CoreData",
            "dependencies": {
                "JobKit/Core": []
            }
        },
        {
            "name": "Headers",
            "source_files": "JobKit/**/*.h",
            "public_header_files": "JobKit/**/*.h"
        }
    ]
}

Pin It on Pinterest

Share This