delba/Tactile

Block support

JiriTrecak opened this issue · 3 comments

Hello,

first, very nice work indeed. What would help this project to be really great is if the methods offered block version instead of target. That way you would be able to do following:

view.on(tap) {
    // Do something
}

Which removes the decoupling - the need to have different method somewhere else in the code.

Thanks for your time doing this library!

Sincerely,
Jiri

delba commented

Hey @JiriTrecak,

Tactile already supports this 😄

All of the followings are equivalent:

1.

view.on(tap, tapped)

// ...

func tapped(tap: UITapGestureRecognizer) {
    print(tap)
}

2.

let tapped = { (tap: UITapGestureRecognizer) -> Void
    print(tap)
}

view.on(tap, tapped)

3.

view.on(tap) { print($0) }

Note that you can also use the shorthand methods:

view.tap { print($0) }

Man am I dumb today! Thanks, and sorry :) (maybe would be nice to highlight it more in the docs)

delba commented

Ahaha no problem! Thanks for Laurine btw 🙏