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

RxTextView.textChangesWithBefore #137

Closed
wKovacs64 opened this issue Sep 13, 2015 · 5 comments
Closed

RxTextView.textChangesWithBefore #137

wKovacs64 opened this issue Sep 13, 2015 · 5 comments

Comments

@wKovacs64
Copy link

New to RxJava and RxBinding, I started out by doing some user input validation previously implemented via TextWatcher. I realized while attempting to leverage the filter operator that the Observable returned from RxTextView.textChanges only emits the new text. Would it be beneficial to add a similar Observable that also emitted the before value (from TextWatcher#beforeTextChanged)?

@JakeWharton
Copy link
Owner

Can you show an example of how you would use it?

On Sun, Sep 13, 2015, 7:27 PM Justin Hall notifications@github.com wrote:

New to RxJava and RxAndroid, I started out by doing some user input
validation previously implemented via TextWatcher. I realized while
attempting to leverage the filter operator that the Observable returned
from RxTextView.textChanges only emits the new text. Would it be
beneficial to add a similar Observable that also emitted the before value
(from TextWatcher#beforeTextChanged
https://developer.android.com/reference/android/text/TextWatcher.html#beforeTextChanged%28java.lang.CharSequence,%20int,%20int,%20int%29
)?


Reply to this email directly or view it on GitHub
#137.

@wKovacs64
Copy link
Author

I was thinking something like:

RxTextView.textChangesWithBefore(textView)
        .filter(this::compareBeforeAndAfter)
        .subscribe(beforeAndAfterPair -> {
            // ...
        });

Just imagining Pair in the example here, haven't put much thought into the best way to represent the two values.

@JakeWharton
Copy link
Owner

Got it. Will look into adding.

On Sun, Sep 13, 2015, 9:05 PM Justin Hall notifications@github.com wrote:

I was thinking something like:

RxTextView.textChangesWithBefore(textView)
.filter(this::compareBeforeAndAfter)
.subscribe(beforeAndAfterPair -> {
// ...
});

Just imagining Pair in the example here, haven't put much thought into
the best way to represent the two values.


Reply to this email directly or view it on GitHub
#137 (comment)
.

@wKovacs64
Copy link
Author

Cool, thanks for considering it.

@xfumihiro
Copy link
Contributor

@wKovacs64 Both before and after text change event bindings are added in #145.
You can then use combine operators with filter to do the job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants