Skip to content

Commit 0b97c26

Browse files
committed
Fix sockeqwe#242 and sockeqwe#303 by internally using ReplaySubject for intents
1 parent 3c8f8f8 commit 0b97c26

File tree

12 files changed

+614
-459
lines changed

12 files changed

+614
-459
lines changed

build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ext {
4949
// Libraries
5050
supportLibVersion = '27.0.2'
5151
rxjava2Version = '2.0.7'
52+
rxAndroid2Version = '2.0.1'
5253

5354

5455
// Libraries for samples

mvi-common/src/main/java/com/hannesdorfmann/mosby3/mvi/DisposableIntentObserver.java

+17-14
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package com.hannesdorfmann.mosby3.mvi;
1919

2020
import io.reactivex.observers.DisposableObserver;
21-
import io.reactivex.subjects.PublishSubject;
21+
import io.reactivex.subjects.Subject;
2222

2323
/**
2424
* Just a simple {@link DisposableObserver} that is used to cancel subscriptions from view's
@@ -29,21 +29,24 @@
2929
*/
3030
class DisposableIntentObserver<I> extends DisposableObserver<I> {
3131

32-
private final PublishSubject<I> subject;
32+
private final Subject<I> subject;
3333

34-
public DisposableIntentObserver(PublishSubject<I> subject) {
35-
this.subject = subject;
36-
}
34+
public DisposableIntentObserver(Subject<I> subject) {
35+
this.subject = subject;
36+
}
3737

38-
@Override public void onNext(I value) {
39-
subject.onNext(value);
40-
}
38+
@Override
39+
public void onNext(I value) {
40+
subject.onNext(value);
41+
}
4142

42-
@Override public void onError(Throwable e) {
43-
throw new IllegalStateException("View intents must not throw errors", e);
44-
}
43+
@Override
44+
public void onError(Throwable e) {
45+
throw new IllegalStateException("View intents must not throw errors", e);
46+
}
4547

46-
@Override public void onComplete() {
47-
subject.onComplete();
48-
}
48+
@Override
49+
public void onComplete() {
50+
subject.onComplete();
51+
}
4952
}

0 commit comments

Comments
 (0)