Skip to content

Commit 6984e9d

Browse files
committed
- RxSearchObservable.kt file added.
1 parent c0f6cb3 commit 6984e9d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.library.rxutil
2+
3+
import android.text.Editable
4+
import android.text.TextWatcher
5+
import android.widget.EditText
6+
import io.reactivex.Observable
7+
import io.reactivex.subjects.PublishSubject
8+
9+
fun EditText.fromView() : Observable<String> {
10+
val publishSubject = PublishSubject.create<String>()
11+
this.addTextChangedListener(object : TextWatcher{
12+
override fun afterTextChanged(s: Editable?) {
13+
publishSubject.onNext(s.toString())
14+
}
15+
16+
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
17+
}
18+
19+
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
20+
}
21+
22+
})
23+
return publishSubject
24+
}

0 commit comments

Comments
 (0)