Skip to content

Proposal: rename / remove "addAction", or add UIButton specific method to attach closure #6

@almostintuitive

Description

@almostintuitive

Hi!

Thanks for this little library, I've been using Actions in production and really like it in general.
There's one thing that got me: for UIButtons, I saw that there's an addAction method, and started using it mindlessly, assuming it'd only trigger on .touchUpInside (which is I guess what 99% of the time what you're interested in if you're adding a closure to a button).
Then I kept adding more and more of those to the codebase, and the number of crashes kept increasing, and it has been really hard to figure out where they're coming from.
Then looked into the code and figured that addAction is triggered every time there's a UIControl action is received - but it was definitely not my first thought (basically only figured it out around 2-3 months in)

Which is completely fine, but this was not obvious to me from the method name. :)
Potentially this may have not been an issue if UIButton had a "addOnTouchUp" or a modified "addTap" method?
Is there any real usecase for "addAction" in general? Even using something like "onAnyAction" would make it 100% clear.

I'm writing this because it may happen to some other people, not just me:).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions