Qwolm 0.1.0

Qwolm 0.1.0

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布上次发布Nov 2017
SwiftSwift 版本4.0
SPM支持 SPM

Mikhail Akopov 维护。



Qwolm 0.1.0

  • Mikhail Akopov

Qwolm

Swift Version
Version
License
Platform

一个简单的工具,用于处理当

  • 新调用的一个长时间运行的任务在它完成之前抵达的情况;
  • 只有最后一次调用的结果才是重要的。

用法

class SomeClass {

	// Define input and output types
	private var qwolm: Qwolm<Int, Int>!

	init() {
		// Initialize with a task and a completion handler
		qwolm = Qwolm(task: complexTask) { output in
			print(output)
		}
	}

	// This function gets called very often
	func execute(input: Int) {
		qwolm.execute(input: input)
	}

	// A difficult task that takes a long time
	private func complexTask(input: Int, completion: @escaping (Int) -> Void) {
		let output = input + 1
		completion(output)
	}

}

示例

要运行示例项目,请克隆仓库,并首先从 Example 目录中运行 pod install

安装

Qwolm 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile

pod 'Qwolm'

然后运行 pod install

作者

Mikhail Akopov, [email protected]

许可证

Qwolm 基于 MIT 许可证可用。有关更多信息,请参阅 LICENSE 文件。