Comments (14)
Are you suggesting that if the initial text is abc
, and it's edited to say abcdef
, then the emitted text should be def
?
from rxbinding.
Are you suggesting that if the initial text is
abc
, and it's edited to sayabcdef
, then the emitted text should bedef
?
According to Delay Operator documentation — yes, because @simpleton delays the emission, not the subscription.
from rxbinding.
Are you not looking for throttle instead? Delay simply delays the emitting of every single item (event), not batch them.
from rxbinding.
This is not an RxBinding issue. These operators are from RxJava. Please use the RxJava mailing list, its issue tracker, or StackOverflow with the rx-java tag.
from rxbinding.
The issue has nothing to do with RxJava
. The real problem is that TextWatcher.onTextChanged
invoked with the same mutable CharSequence
instance, so typing a new character into EditText
will make all delayed values invalid.
from rxbinding.
.map(String::valueOf)
? I'm not sure a defensive copy is the right default behavior.
from rxbinding.
+1 just checked delay
in RxJava, it works according to documentation.
from rxbinding.
I'll re-open for discussion around it, @nsk-mironov.
from rxbinding.
I think defensive copy of CharSequence
is required because somebody may use observeOn()
(or just multithreading in some operator) and do some async work with this CharSequence
.
But the problem is that CharSequence
is just an interface without copy()
, though it's possible to do "copy" via subSequence(0, length() - 1)
, but some implementation of CharSequence
may return non-fair copy…
I guess, for now, best RxBindings can do — is recommend (in javadoc) to map
CharSequence
to the String
if user wants to do async processing.
from rxbinding.
I don't really think the issue needs to be fixed. There are some other operators that are affected by the same problem (e.g. ViewTouchOnSubscribe
and ViewHoverOnSubscribe
since both of them are using MotionEvent
which can be recycled by android). Fixing TextViewTextOnSubscribe
will imply fixing those operators as well.
The best thing we can do is explicitly mention in the documentation that these operators are not supposed to be used with other scheduling related operators.
from rxbinding.
Yep, agreed. Will use this issue to track.
from rxbinding.
Since RxTextView.textChanges()
looks like one of the most useful and popular binding, I think we should make it as safe as possible.
Mutability of the text from the user input may lead to a lot of hardly-discoverable problems in many apps (async processing, operators such as distinct
, buffer
, window
and so on).
Proposal:
What if RxTextView.textChanges()
will return String
(-> unmodifiable).
For those who need CharSequence
we will add RxTextView.rawTextChanges()
with huge warning about the mutability of values in the javadoc.
MotionEvent
is a special case, the fact that Framework has a pool of them and that MotionEvent
is mutable described in the Documentation to the SDK, so it's fine for RxBindings too.
But far less developers know about mutability of CharSequence
emitted by the TextView
(I didn't know until @nsk-mironov commented here), with RxJava (async code as first-class citizen) + mutable values chances to shoot yourself in the foot are much higher!
from rxbinding.
I, pakoito, being of sound mind and body, wholeheartedly agree with artem-zinnatullin proposal of desambiguation.
My reason is that I saw some misbehaviour with textChanges() + distinctUntilChanged() + other operators like debounce().
from rxbinding.
+1 to artem-zinnatullin's proposal. Observable of String would be highly desirable.
from rxbinding.
Related Issues (20)
- Idea - Coroutine Support HOT 3
- androidx.appcompat.widget.SearchView support HOT 3
- Migrate to GitHub actions HOT 1
- Failed to resolve: com.jakewharton.rxbinding4:rxbinding:4.0.0 HOT 2
- I use RxView By Kotlin ,no find RxView but Java is ok. HOT 2
- How detect long press in Rxview .Touches HOT 1
- View click throttleFirst another way HOT 1
- RecyclerView can't use itemClicks HOT 1
- RxView.clicks needs tow clicks HOT 1
- throttleFirst way to avoid multiple clicks invalid when app first launched HOT 1
- Bug in comment for TextView.editorActions(handled: (Int) -> Boolean = AlwaysTrue)
- Getting java.lang.IllegalStateException: Expected to be called on the main thread but was RxCachedThreadScheduler HOT 1
- How to control BottomNavigationView.onNavigationItemSelected click switch fragment HOT 3
- Kotlin cannot recognize rxview, rxtextview HOT 2
- Version correspondence HOT 1
- RxView.clicks needs tow clicks
- Quest
- Observable textChanges() rxBinding4 HOT 2
- Run cb cmd command....qds
- Exception: No static method checkUiThread HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxbinding.