当前位置: 首页>>代码示例>>Java>>正文


Java CompletableEmitter.onComplete方法代码示例

本文整理汇总了Java中io.reactivex.CompletableEmitter.onComplete方法的典型用法代码示例。如果您正苦于以下问题:Java CompletableEmitter.onComplete方法的具体用法?Java CompletableEmitter.onComplete怎么用?Java CompletableEmitter.onComplete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.reactivex.CompletableEmitter的用法示例。


在下文中一共展示了CompletableEmitter.onComplete方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: subscribe

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {

    final OnCompleteListener<T> listener = new OnCompleteListener<T>() {
        @Override
        public void onComplete(@NonNull Task<T> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    database.runTransaction(transaction).addOnCompleteListener(listener);
}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:21,代码来源:RunTransactionOnSubscribe.java

示例2: subscribe

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
    final OnCompleteListener<Void> listener = new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    batch.commit().addOnCompleteListener(listener);
}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:20,代码来源:CommitBatchOnSubscribe.java

示例3: subscribe

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
    final OnCompleteListener<Void> listener = new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    reference.set(value).addOnCompleteListener(listener);

}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:21,代码来源:SetOnSubscribe.java

示例4: subscribe

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
    final OnCompleteListener<Void> listener = new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    reference.delete().addOnCompleteListener(listener);
}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:20,代码来源:DeleteOnSubscribe.java

示例5: subscribe

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
    final OnCompleteListener<DocumentReference> listener =
            new OnCompleteListener<DocumentReference>() {
                @Override
                public void onComplete(@NonNull Task<DocumentReference> task) {

                    if (!emitter.isDisposed()) {
                        if (!task.isSuccessful()) {
                            emitter.onError(task.getException());
                        } else {
                            emitter.onComplete();
                        }
                    }

                }
            };

    reference.add(value).addOnCompleteListener(listener);
}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:21,代码来源:AddOnSubscribe.java

示例6: subscribe

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
    final OnCompleteListener<Void> listener = new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    reference.update(updates).addOnCompleteListener(listener);

}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:21,代码来源:UpdateOnSubscribe.java

示例7: listener

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
/**
 * @param emit
 * @param <R>
 * @return
 */
@NonNull
@CheckReturnValue
public static <R> OnCompleteListener<R> listener(@NonNull final CompletableEmitter emit) {
    return new OnCompleteListener<R>() {
        @Override
        public void onComplete(@NonNull final Task<R> task) {
            if (!emit.isDisposed()) {
                if (task.isSuccessful()) {
                    emit.onComplete();
                } else {
                    Exception e = task.getException();
                    emit.onError(e != null ? e : new RuntimeException());
                }
            }
        }
    };
}
 
开发者ID:yongjhih,项目名称:rxtasks,代码行数:23,代码来源:RxTask.java

示例8: listener

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
public static OnCompleteListener<Void> listener(@NonNull final CompletableEmitter emitter) {
  return new OnCompleteListener<Void>() {
    @Override public void onComplete(@NonNull Task<Void> task) {
      if (!task.isSuccessful()) {
        if (!emitter.isDisposed()) {
          emitter.onError(task.getException());
        }
        return;
      }

      if (!emitter.isDisposed()) {
        emitter.onComplete();
      }
    }
  };
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:17,代码来源:GmsTaskListeners.java

示例9: subscribe

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
@Override public void subscribe(final CompletableEmitter emitter) {
  final Transaction.Handler handler = new Transaction.Handler() {
    @Override public Transaction.Result doTransaction(MutableData mutableData) {
      try {
        return task.apply(mutableData);
      } catch (Exception e) {
        //TODO: Is this enough?
        throw new RuntimeException(e);
      }
    }

    @Override public void onComplete(DatabaseError databaseError, boolean committed,
        DataSnapshot dataSnapshot) {
      if (!emitter.isDisposed()) {
        if (null == databaseError) {
          emitter.onComplete();
        } else {
          emitter.onError(databaseError.toException());
        }
      }
    }
  };

  ref.runTransaction(handler, fireLocalEvents);
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:26,代码来源:RunTransactionOnSubscribe.java

示例10: getOnCompleteSignInListener

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
private OnCompleteListener<AuthResult> getOnCompleteSignInListener(final CompletableEmitter emitter) {
    return task -> {
        if (task.isSuccessful()) {
            mEventHub.post(new SignInEvent());
            emitter.onComplete();
        } else {
            emitter.onError(task.getException());
        }
    };
}
 
开发者ID:Vovchyk,项目名称:android-rss-feed-reader,代码行数:11,代码来源:UserManager.java

示例11: subscribe

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(CompletableEmitter emitter) {
    if (!emitter.isDisposed()) {
        instance.signOut();
        emitter.onComplete();
    }
}
 
开发者ID:yongjhih,项目名称:rxfirebase,代码行数:8,代码来源:SignOutOnSubscribe.java

示例12: subscribe

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
@Override
public void subscribe(@NonNull CompletableEmitter emitter) throws Exception {
    try {
        preparedOperation.executeAsBlocking();
        emitter.onComplete();
    } catch (Exception e) {
        emitter.onError(e);
    }
}
 
开发者ID:pushtorefresh,项目名称:storio,代码行数:10,代码来源:CompletableOnSubscribeExecuteAsBlocking.java

示例13: subscribe

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
/**
 * Delete all documents in a collection. Uses an Executor to perform work on a background
 * thread. This does *not* automatically discover and delete subcollections.
 */
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {

    final OnCompleteListener<Void> listener = new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    Callable<Void> callable = new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            // Get the first batch of documents in the collection
            Query query = collectionReference.orderBy(FieldPath.documentId()).limit(batchSize);

            // Get a list of deleted documents
            List<DocumentSnapshot> deleted = deleteQueryBatch(query);

            // While the deleted documents in the last batch indicate that there
            // may still be more documents in the collection, page down to the
            // next batch and delete again
            while (deleted.size() >= batchSize) {
                // Move the query cursor to start after the last doc in the batch
                DocumentSnapshot last = deleted.get(deleted.size() - 1);
                query = collectionReference.orderBy(FieldPath.documentId())
                        .startAfter(last.getId())
                        .limit(batchSize);

                deleted = deleteQueryBatch(query);
            }

            return null;
        }
    };


    Tasks.call(executor, callable).addOnCompleteListener(listener);
}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:52,代码来源:DeleteCollectionOnSubscribe.java

示例14: subscribe

import io.reactivex.CompletableEmitter; //导入方法依赖的package包/类
@Override public void subscribe(CompletableEmitter emitter) {
  if (!emitter.isDisposed()) {
    instance.signOut();
    emitter.onComplete();
  }
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:7,代码来源:SignOutOnSubscribe.java


注:本文中的io.reactivex.CompletableEmitter.onComplete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。