Skip to content

Instantly share code, notes, and snippets.

@sandofsky
Created October 5, 2015 22:12
Show Gist options
  • Save sandofsky/c58f86644205e6c5183d to your computer and use it in GitHub Desktop.
Save sandofsky/c58f86644205e6c5183d to your computer and use it in GitHub Desktop.
typealias Callback = () -> ()
// Both methods are required
class Something {
var calledOnce:Callback?
var calledMultipleTimes:Callback?
}
@thekarladam
Copy link

Here ya go:

class SomeUsefulProcessDelinquent<InputType, ResultType> {
    typealias CallMeWhenYouWannaMapMe = (InputType) -> ResultType
    typealias CallMeWhenYouWannaChangeMe = ([InputType]) -> [ResultType]

    let mapClosure : CallMeWhenYouWannaMapMe
    let updateClosure : CallMeWhenYouWannaChangeMe

    init(mapFunction : CallMeWhenYouWannaMapMe, updateFunction : CallMeWhenYouWannaChangeMe) {
        self.mapClosure = mapFunction
        self.updateClosure = updateFunction
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment