CocoaPods trunk is moving to be read-only. Read more on the blog, there are 13 months to go.
| TestsTested | ✓ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Mar 2016 |
| SPMSupports SPM | ✗ |
Maintained by Hiromune Ito.
Happa is a library to control when to execute function with closed scope context.
Happa is available through CocoaPods.
Add the followings to Podfile:
platform :ios, '8.0'
use_frameworks!
pod "Happa"Then, run the command
$ pod installThis is a simple usage. See Examples for more complex examples.
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 is available under the MIT license. See the LICENSE file for more info.