Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove .distinctUntilChanged() in UIControl.rx_value #626

Closed
RobinFalko opened this issue Apr 18, 2016 · 3 comments
Closed

Remove .distinctUntilChanged() in UIControl.rx_value #626

RobinFalko opened this issue Apr 18, 2016 · 3 comments
Labels

Comments

@RobinFalko
Copy link

rx_value in extension UIControl (RxCocoa.UIControl+Rx.swift) shouldn't call .distinctUntilChanged() since it manipulates the native event behavior of a UIControl. Imho it should be up to the developer to call .distinctUntilChanged() or not.

E.g. the developer wants to limit the character input within a UITextField, .distinctUntilChanged() will prevent the developer from manipulating the input from every second event if the second content is equal to the previous content because the second event won't be dispatched at all.

textField.rx_text
            .map { text in
                text = [remove special characters from 'text' and assign the result to 'text' again]
                return text
            }
            .bindTo(textField.rx_text)
            .addDisposableTo(disposeBag)
@kzaher
Copy link
Member

kzaher commented Apr 18, 2016

Hi @RobinFalko ,

What a sense for timing :) You are correct. I've encountered similar issues yesterday, and already removed all distinctUntilChanged. I've pushed my changes to develop branch :)

72edf86

Please let me know if you find some other places we should remove distinctUntilChanged from.

@kzaher kzaher added the bug label Apr 26, 2016
@HarveyHu
Copy link

I've just encountered a similar problem about UISwitch.rx_value.
I tried to call an uialertview with an inputTextField when UISwitch.rx_value is changing, in order to confirm this user has correct password for this operation.
if not, I'll change mySwitch.on to original setting programmatically.
However, uialertview didn't appear next time because distinctUntilChanged have blocked it.
I even tried to emit a new rx_value signal to reseting the previous rx_value, but I can't send any rx_value signal programmatically.
I think the solution of this issue will solve my problem as well. thank you all.

@kzaher
Copy link
Member

kzaher commented May 15, 2016

This one is just released.

@kzaher kzaher closed this as completed May 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants