-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathMyApplication.java
42 lines (31 loc) · 936 Bytes
/
MyApplication.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.rxjava2.android.samples;
import android.app.Application;
import com.rxjava2.android.samples.model.Events;
import com.rxjava2.android.samples.ui.rxbus.RxBus;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.functions.Consumer;
/**
* Created by threshold on 2017/1/12.
*/
public class MyApplication extends Application {
public static final String TAG = "MyApplication";
private RxBus bus;
@Override
public void onCreate() {
super.onCreate();
bus = new RxBus();
}
public RxBus bus() {
return bus;
}
public void sendAutoEvent() {
Observable.timer(2, TimeUnit.SECONDS)
.subscribe(new Consumer<Long>() {
@Override
public void accept(Long aLong) {
bus.send(new Events.AutoEvent());
}
});
}
}