gontovnik / DGRunkeeperSwitch

Runkeeper design switch control
MIT License
1.88k stars 175 forks source link

add protocol #38

Closed zmarvin closed 7 years ago

zmarvin commented 7 years ago

I think add two protocol methods to communicate with the outside, so that before the switch state changes, give the user an opportunity to choose whether or not to change.

efremidze commented 7 years ago

Can u provide a use case?

zmarvin commented 7 years ago

There are many signals that produce errors, such as network requests, loading local data, and so on. So when the switch affects such a signal, you need to wait for the appearance of the results to determine whether to change the state of the switch.

efremidze commented 7 years ago

The did change state is unnecessary. You should use this instead:

runkeeperSwitch.addTarget(self, action: #selector(ViewController.switchValueDidChange(sender:)), for: .valueChanged)

Also the will change might not be necessary. You can always fork and add that. Ill ask the owner of the repo.

zmarvin commented 7 years ago

You're right, this is just my advice, depending on the author's meaning, Cocoa had a lot of controls to achieve a similar protocol.

gontovnik commented 7 years ago

Sorry, but I believe that it is not needed.