Happa 0.0.1

Happa 0.0.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2016
SPMSupports SPM

Maintained by Hiromune Ito.



Happa 0.0.1

  • By
  • Hiromune Ito

Happa is a library to control when to execute function with closed scope context.

Requirements

  • iOS 8.0+
  • Xcode 7.2+

Installation

Happa is available through CocoaPods.

Add the followings to Podfile:

platform :ios, '8.0'
use_frameworks!

pod "Happa"

Then, run the command

$ pod install

Usage

This 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
  }
})

License

Happa is available under the MIT license. See the LICENSE file for more info.