eliotfowler / EFCircularSlider

An extensible circular slider for iOS applications
http://eliotfowler.github.io/EFCircularSlider/
MIT License
998 stars 161 forks source link

Breaking a feedback loop, while setting currentValue property #22

Closed DenTelezhkin closed 7 years ago

DenTelezhkin commented 10 years ago

Hello there! Let me explain a bit my use case scenario and the reason i'm sending this PR.

So basically i'm implementing audio player, that uses EFCircularSlider as a progress bar for the audio track. And i have basically two workflows:

  1. User is able to move handle to change progress on the audio track, rewinding back and forward.
  2. Progress for the audio track is updated automatically, while audio is playing.

To achieve first, i'm subscribing to UIControlEventValueChanged action, read EFCircularSlider currentValue and transfer it to my audio player. To achieve second, i have a timer, that fires every 0.1 seconds, that reads current progress of the audio track, and sets currentValue property on EFCircularSlider.

These two things create a endless feedback loop with currentValue property. To break it, a made a method on EFCircularSlider, that set's currentValue property without sending UIControlEventValueChanged action.

Takha25 commented 8 years ago

Thanks, tried your improvement. I'd encountered the same problem with continuous loop. After suggested corrections the loop has gone. But now valueChanged event doesn't fire at all even if rotate by hand.

DenTelezhkin commented 8 years ago

I believe it should. The only thing this PR does is follow usual Apple's convention:

  1. When control changes are user-driven, send UIControlEvent
  2. When control changes are developer-driven, do them silently without additional events.

I'm using workaround included here in the app, that has been working since 2014 actually =) Seems like this repo is abandoned, which is unfortunate, cause control is nice.

Takha25 commented 8 years ago

You are right: everything works like a charm, thanks!

DenTelezhkin commented 7 years ago

This looks reaaaally stale.