JakeWharton / RxBinding

RxJava binding APIs for Android's UI widgets.
Apache License 2.0
9.69k stars 971 forks source link

How to implement removeTextChangeListener in RxTextView? #276

Closed kagile closed 8 years ago

kagile commented 8 years ago

There is nothing I found in the documentation for RxTextView. Should I use ConnectableObserver?

JakeWharton commented 8 years ago

Text change listeners are automatically removed when you unsubscribe from the observable.

JakeWharton commented 8 years ago

When you call subscribe on the returned observable from a method like RxTextView.textChanges() we add the text watcher to the TextView. When you call unsubscribe it is automatically removed. You don't have to do anything beyond use the Observable like any other.

kagile commented 8 years ago

But how to add then remove and then add TextWatcher again? Do I subscribe then unsubscribe and then subscribe again? Wouldn't it have side effects?

JakeWharton commented 8 years ago

Re-subscribing re-adds the text watcher, yes. The act of subscribing and unsubscribing has the side-effect of adding and removing the watcher.

On Wed, Aug 10, 2016 at 1:33 AM krupalagile notifications@github.com wrote:

But how to add then remove and then add TextWatcher again? Do I subscribe then unsubscribe and then subscribe again? Wouldn't it have side effects?

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/JakeWharton/RxBinding/issues/276#issuecomment-238770077, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEfGByT58rvkQUJcQmi-2MUi6vQesks5qeWK0gaJpZM4JgAd- .

smedic commented 5 years ago

Hi. What I need is to use RxTextView.textChanges and monitor for EditText changes in adapter. Problem with this is that in onBindViewHolder I must remove text change listener and after setting all views, attach it again. It's simple with TextWatcher, but how to do that with Rx binding?

There is not Subscription anymore, and trying to use disposable.clear() on start and attach RxTextView.textChanges is not functional. It does not emit anything.