JobKit 0.9.0

JobKit 0.9.0

测试测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年4月

Cristian Bica 维护。



JobKit 0.9.0

警告:该项目处于 alpha 状态

关于

JobKit 是 iOS 应用程序的任务排队系统。它有一个可插拔的存储适配器,该存储库包含 Core Data(持久)、Realm(持久)和内存适配器。

目前,它在移动设备上的实现相对简单,因为它会定期(tickInterval)检查新任务,但我会实现基于通知的处理触发器。

安装

JobKit 可通过CocoaPods获得。要安装它,只需将以下行添加到您的 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"

使用

在您的 AppDelegate 中初始化 JobKit

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

您可以通过以下三种方式将任务添加到 JobKit 的队列中:

1 - 创建 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"}]];

重要:所有参数都必须遵守 NSCoding 协议。

2 - 为任何对象编排调用类方法

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

重要:所有参数都必须遵守 NSCoding 协议。

3 - 为任何对象实例编排调用实例方法

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

重要:对象和所有参数都必须遵守 NSCoding 协议。

待办事项

  1. 优化作业处理触发
  2. 实现重试机制
  3. 查询作业接口
  4. 作业的 UI
  5. 在将来/有延迟时安排作业
  6. 在后台模式下处理作业

作者

Cristian Bica,[email protected]

许可证

JobKit 可在CocoaPods下使用 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。