Happa 0.0.1

Happa 0.0.1

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最后发布2016年3月
SPM支持 SPM

Hiromune Ito 维护。



Happa 0.0.1

  • Hiromune Ito

Happa 是一个库,用于控制何时以封闭作用域的上下文执行函数。

要求

  • iOS 8.0+
  • Xcode 7.2+

安装

Happa 通过 CocoaPods 提供。

将以下内容添加到 Podfile

platform :ios, '8.0'
use_frameworks!

pod "Happa"

然后,运行命令

$ pod install

用法

这是一个简单的用法。有关更复杂的示例,请参阅 示例

import Happa

let context = Happa<Int>(
  state: 2,
  cond: { (current: Int) -> Bool in
    return current <= 0
  },
  fire: { (current: Int) -> Void in
    print("current value: \(current)")
  }
)

asyncFunc1(completion: {
  // not fire
  context.update { (current: Int) -> Int in
    return current - 1
  }
})

asyncFunc2(completion: {
  // fire
  context.update { (current: Int) -> Int in
    return current - 1
  }
})

asyncFunc3(completion: {
  // more fire
  context.update { (current: Int) -> Int in
    return current - 1
  }
})

许可证

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