Skip to content

Instantly share code, notes, and snippets.

@swift2931
Created January 26, 2019 10:48
Show Gist options
  • Save swift2931/89d3dec47afb5c312ae53b974b7ad27e to your computer and use it in GitHub Desktop.
Save swift2931/89d3dec47afb5c312ae53b974b7ad27e to your computer and use it in GitHub Desktop.
Elf
import UIKit
func dp(_ any: Any...) {
print(any)
}
protocol Redux: class {
func action(_ f: String) -> (Self) -> ()
func effect(_ f: String) -> Self
func effect(_ desc: String, _ cls: () -> ()) -> Self
}
extension Redux {
var marker: String {
return " ----------------------------------"
}
func action(_ f: String = #function) -> (Self) -> () {
dp(f+marker)
return {_ in }
}
func effect(_ f: String = #function) -> Self {
dp(f)
return self
}
func effect(_ desc: String, _ cls: () -> ()) -> Self {
dp(desc)
cls()
return self
}
}
infix operator <<
func <<<T>(_ lhs: (T) -> (), _ rhs: T) {
lhs(rhs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment