本文整理汇总了Java中io.reactivex.ObservableEmitter.setDisposable方法的典型用法代码示例。如果您正苦于以下问题:Java ObservableEmitter.setDisposable方法的具体用法?Java ObservableEmitter.setDisposable怎么用?Java ObservableEmitter.setDisposable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.ObservableEmitter
的用法示例。
在下文中一共展示了ObservableEmitter.setDisposable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override public void subscribe(final ObservableEmitter<FirebaseAuth> emitter) {
final FirebaseAuth.AuthStateListener listener = new FirebaseAuth.AuthStateListener() {
@Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
if (!emitter.isDisposed()) {
emitter.onNext(firebaseAuth);
}
}
};
instance.addAuthStateListener(listener);
emitter.setDisposable(Disposables.fromAction(new Action() {
@Override public void run() throws Exception {
instance.removeAuthStateListener(listener);
}
}));
}
示例2: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final ObservableEmitter<DocumentSnapshot> emitter) throws Exception {
final EventListener<DocumentSnapshot> listener = new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(DocumentSnapshot documentSnapshot, FirebaseFirestoreException e) {
if (!emitter.isDisposed()) {
if (e == null) {
emitter.onNext(documentSnapshot);
} else {
emitter.onError(e);
}
}
}
};
registration = documentReference.addSnapshotListener(listener);
emitter.setDisposable(Disposables.fromAction(new Action() {
@Override
public void run() throws Exception {
registration.remove();
}
}));
}
示例3: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override public void subscribe(final ObservableEmitter<DataSnapshot> emitter) {
final ValueEventListener listener = new ValueEventListener() {
@Override public void onDataChange(DataSnapshot dataSnapshot) {
if (!emitter.isDisposed()) {
emitter.onNext(dataSnapshot);
}
}
@Override public void onCancelled(DatabaseError databaseError) {
if (!emitter.isDisposed()) {
emitter.onError(databaseError.toException());
}
}
};
ref.addValueEventListener(listener);
emitter.setDisposable(Disposables.fromAction(new Action() {
@Override public void run() throws Exception {
ref.removeEventListener(listener);
}
}));
}
示例4: setDisposable
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
private void setDisposable(ObservableEmitter<T> emitter) {
emitter.setDisposable(Disposables.fromAction(() -> {
synchronized (this) {
emitters.remove(emitter);
}
}));
}
示例5: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final ObservableEmitter<QuerySnapshot> emitter) throws Exception {
final EventListener<QuerySnapshot> listener = new EventListener<QuerySnapshot>() {
@Override
public void onEvent(QuerySnapshot querySnapshot, FirebaseFirestoreException e) {
if (!emitter.isDisposed()) {
if (e == null) {
emitter.onNext(querySnapshot);
} else {
emitter.onError(e);
}
}
}
};
registration = query.addSnapshotListener(listener);
emitter.setDisposable(Disposables.fromAction(new Action() {
@Override
public void run() throws Exception {
registration.remove();
}
}));
}
示例6: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final ObservableEmitter<DocumentChange> emitter) throws Exception {
final EventListener<QuerySnapshot> listener = new EventListener<QuerySnapshot>() {
@Override
public void onEvent(QuerySnapshot querySnapshot, FirebaseFirestoreException e) {
if (!emitter.isDisposed()) {
if (e == null) {
for (DocumentChange change : querySnapshot.getDocumentChanges()) {
emitter.onNext(change);
}
} else {
emitter.onError(e);
}
}
}
};
registration = query.addSnapshotListener(listener);
emitter.setDisposable(Disposables.fromAction(new Action() {
@Override
public void run() throws Exception {
registration.remove();
}
}));
}
示例7: subscribe
import io.reactivex.ObservableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(ObservableEmitter<Object> emitter) throws Exception {
verifyMainThread();
EmitterListener listener = new EmitterListener(emitter);
emitter.setDisposable(listener);
view.addOnAttachStateChangeListener(listener);
}