thomasnield
04/30/2017, 3:15 PMobserveOn()
, subscribeOn()
, and unsubscribeOn()
would directly accept a CoroutineDispatcher
instead of a Scheduler
backed by a CoroutineDispatcher
?thomasnield
05/02/2017, 12:19 AMPaul Woitaschek
05/09/2017, 5:40 PMtrevjones
05/10/2017, 9:16 PMzak.taccardi
05/10/2017, 9:21 PMfun dataEmissions() : Observable<YourData>()
and fun executeNetworkRequest(params: Params)
(note 2nd method returns void).muthuraj
05/12/2017, 2:17 PMCompletable.create { }
the CompletableOnSubscribe
becomes null.
Completable.create((CompletableOnSubscribe)null.INSTANCE);
this is the decompiled version.
Since it becomes null, anything I put inside create doesn’t work.
But if I use
Completable.create(object : CompletableOnSubscribe{
override fun subscribe(e: CompletableEmitter?) {
}
})like this, then it is working fine.
thomasnield
05/18/2017, 12:19 PMmg6maciej
06/05/2017, 9:38 PMuzias
06/19/2017, 5:49 PMgregd
06/25/2017, 6:49 PMgregd
06/26/2017, 7:59 PMvararg
all the elements will have to be of the same type (e.g. Observable<String>
). So if your form has various types, this might me a problem. Maybe it would be better to use something like Observable.combineLatest()
, which is parametrized (generics) and can handle up to 9 different Observables?thomasnield
07/03/2017, 9:33 PMthomasnield
07/17/2017, 3:54 PMpeasee
07/24/2017, 8:50 AMdarkmoon_uk
07/24/2017, 1:43 PMtulio
07/24/2017, 5:53 PMtschuchort
07/24/2017, 7:23 PMthomasnield
08/01/2017, 4:56 AMHawazine Haouat
08/01/2017, 4:28 PMkioba
08/07/2017, 9:00 PM.concat
for is offline sync, so it depends on heavily what you meant on local observable.
Basically he concat the 3 datasource and take the first available. So if you don’t have in the upper layers then you go deeper to the more expensive ones and update the upper ones.
answering you question i would go with both of them, take local or network with the most uptodate data, but on the network call just update the local:
fun getDistinctUsers() = Observable
.concat(local, network.doOnNext{ data -> saveToLocal(data)})
.first {data -> data.synced }
.filter(SomeAlgorithm::distinct)
gabrielfv
08/11/2017, 1:57 AMadolgiy
08/21/2017, 9:25 PMf.babic
08/24/2017, 11:16 AMalexsullivan114
08/28/2017, 6:18 PMObservable.just("Foo")
.map { "Bar" }
.filter { it == "Baz" }
.doOnNext { print("Bat") }
.subscribe { print(it) }
if I try to autoformat it, it puts all the function calls on one line - i.e. it becomes this:
Observable.just("Foo").map { "Bar" }.filter { it == "Baz" }.doOnNext { print("Bat") }.subscribe { print(it) }
What option do I need to change in the kotlin code styles to keep the newlines?igorbiscanin
09/07/2017, 9:27 AMError:(114, 36) None of the following functions can be called with the arguments supplied:
@CheckReturnValue @SchedulerSupport public final fun <T1 : Any!, T2 : Any!, R : Any!> combineLatest(p0: ((Observer<in String!>) -> Unit)!, p1: ((Observer<in String!>) -> Unit)!, p2: ((String, String) -> Boolean)!): Observable<Boolean!>! defined in io.reactivex.Observable
@CheckReturnValue @SchedulerSupport public final fun <T : Any!, R : Any!> combineLatest(p0: ((Array<(out) Any!>) -> ???)!, p1: Int, p2: Array<(out) ObservableSource<out (???..???)>!>!): Observable<(???..???)>! defined in io.reactivex.Observable
@CheckReturnValue @SchedulerSupport public open fun <T1 : Any!, T2 : Any!, R : Any!> combineLatest(p0: ObservableSource<out (???..???)>!, p1: ObservableSource<out (???..???)>!, p2: BiFunction<in (???..???), in (???..???), out (???..???)>!): Observable<(???..???)>! defined in io.reactivex.Observable
@CheckReturnValue @SchedulerSupport public open fun <T : Any!, R : Any!> combineLatest(p0: Function<in Array<(out) Any!>!, out (???..???)>!, p1: Int, vararg p2: ObservableSource<out (???..???)>!): Observable<(???..???)>! defined in io.reactivex.Observable
@CheckReturnValue @SchedulerSupport public final fun <T : Any!, R : Any!> combineLatest(p0: Array<(out) ObservableSource<out (???..???)>!>!, p1: ((Array<(out) Any!>) -> ???)!, p2: Int): Observable<(???..???)>! defined in io.reactivex.Observable
@CheckReturnValue @SchedulerSupport public open fun <T : Any!, R : Any!> combineLatest(p0: Array<(out) ObservableSource<out (???..???)>!>!, p1: Function<in Array<(out) Any!>!, out (???..???)>!, p2: Int): Observable<(???..???)>! defined in io.reactivex.Observable
@CheckReturnValue @SchedulerSupport public final fun <T : Any!, R : Any!> combineLatest(p0: (Mutable)Iterable<ObservableSource<out (???..???)>!>!, p1: ((Array<(out) Any!>) -> ???)!, p2: Int): Observable<(???..???)>! defined in io.reactivex.Observable
@CheckReturnValue @SchedulerSupport public open fun <T : Any!, R : Any!> combineLatest(p0: (Mutable)Iterable<ObservableSource<out (???..???)>!>!, p1: Function<in Array<(out) Any!>!, out (???..???)>!, p2: Int): Observable<(???..???)>! defined in io.reactivex.Observable
code sample:
val usernameObservable = RxTextView.textChanges(et_username)
.map { it -> Constants.emailPattern.matcher(it).matches() }
.distinctUntilChanged()
.subscribe()
val passwordObservable = RxTextView.textChanges(et_password)
.map { it -> it.isNotEmpty()}
.distinctUntilChanged()
.subscribe()
val signInEnabledCondition = BiFunction({ username: CharSequence, password: CharSequence ->
username.isNotEmpty() && password.isNotEmpty()
})
val isSignInEnabled = Observable.combineLatest(usernameObservable, passwordObservable, signInEnabledCondition)
isSignInEnabled.distinctUntilChanged().subscribe { enabled: Boolean -> bt_sign_in.isEnabled = enabled }
jw
09/09/2017, 11:36 PMalex.hart
09/11/2017, 12:48 PMartem_zin
09/11/2017, 4:22 PMAsyncTask
trevjones
09/11/2017, 5:07 PMthomasnield
09/11/2017, 11:28 PMthomasnield
09/11/2017, 11:28 PMbamdmux
09/12/2017, 7:15 AM