Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cristianbica/jobkit
JobKit is a job queueing system for iOS application
https://github.com/cristianbica/jobkit
ios jobs objective-c
Last synced: 23 days ago
JSON representation
JobKit is a job queueing system for iOS application
- Host: GitHub
- URL: https://github.com/cristianbica/jobkit
- Owner: cristianbica
- License: mit
- Created: 2015-04-07T12:02:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-24T06:56:44.000Z (about 8 years ago)
- Last Synced: 2024-10-04T18:27:05.501Z (about 1 month ago)
- Topics: ios, jobs, objective-c
- Language: Objective-C
- Homepage:
- Size: 46.9 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JobKit
[![CI Status](http://img.shields.io/travis/cristianbica/JobKit.svg?style=flat)](https://travis-ci.org/cristianbica/JobKit)
[![Version](https://img.shields.io/cocoapods/v/JobKit.svg?style=flat)](http://cocoapods.org/pods/JobKit)
[![License](https://img.shields.io/cocoapods/l/JobKit.svg?style=flat)](http://cocoapods.org/pods/JobKit)
[![Platform](https://img.shields.io/cocoapods/p/JobKit.svg?style=flat)](http://cocoapods.org/pods/JobKit)**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](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
# 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:```objective-c
//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`
```objective-c
@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
```objective-c
@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
```objective-c
@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.