File tree 2 files changed +8
-4
lines changed
src/main/java/ch/petikoch/examples/mvvm_rxjava/example5a
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 17
17
18
18
import ch .petikoch .examples .mvvm_rxjava .datatypes .NameFirstname ;
19
19
import ch .petikoch .examples .mvvm_rxjava .rxjava_mvvm .FinishedIndicator ;
20
- import ch .petikoch .examples .mvvm_rxjava .utils .AsyncUtils ;
21
20
import ch .petikoch .examples .mvvm_rxjava .utils .SysOutUtils ;
22
21
import net .jcip .annotations .ThreadSafe ;
23
22
import rx .Single ;
23
+ import rx .schedulers .Schedulers ;
24
24
25
25
@ ThreadSafe
26
26
class Example_5a_Model {
27
27
28
28
public Single <FinishedIndicator > createAccount (NameFirstname nameFirstname ) {
29
- return AsyncUtils .< FinishedIndicator > executeAsync (() -> {
29
+ return Single . fromCallable (() -> {
30
30
try {
31
31
SysOutUtils .sysout ("Processing: " + nameFirstname .toString ());
32
32
Thread .sleep (5000 ); // = Simulation of a "very slow" backend
33
33
SysOutUtils .sysout ("Finished: " + nameFirstname .toString ());
34
34
} catch (InterruptedException e ) {
35
35
SysOutUtils .sysout ("Interrupted (=cancelled) -> good!" );
36
36
}
37
- });
37
+ return FinishedIndicator .INSTANCE ;
38
+ }).subscribeOn (Schedulers .io ());
38
39
}
39
40
40
41
}
Original file line number Diff line number Diff line change @@ -70,7 +70,10 @@ private void wireInternally() {
70
70
public void connectTo (final Example_5a_Model model ) {
71
71
onEventFrom (vm2m_nameFirstname ).executeAsync (nameFirstname -> {
72
72
73
- Single .merge (model .createAccount (nameFirstname ), v2vm_cancelButtonEvents .first ().toSingle ())
73
+ Single .merge (
74
+ model .createAccount (nameFirstname ),
75
+ v2vm_cancelButtonEvents .first ().toSingle ()
76
+ )
74
77
.toBlocking ()
75
78
.first ();
76
79
You can’t perform that action at this time.
0 commit comments