本文整理汇总了Java中com.google.firebase.database.Transaction.Result方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.Result方法的具体用法?Java Transaction.Result怎么用?Java Transaction.Result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.firebase.database.Transaction
的用法示例。
在下文中一共展示了Transaction.Result方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribe
import com.google.firebase.database.Transaction; //导入方法依赖的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);
}
示例2: transaction
import com.google.firebase.database.Transaction; //导入方法依赖的package包/类
/**
* @param ref
* @param function
* @return
*/
@NonNull
@CheckReturnValue
public static Single<DataSnapshot> transaction(
@NonNull final DatabaseReference ref,
@NonNull final Function<MutableData, Transaction.Result> function) {
return Single.create(new SingleOnSubscribe<DataSnapshot>() {
@Override
public void subscribe(
@NonNull final SingleEmitter<DataSnapshot> emit) throws Exception {
ref.runTransaction(transaction(emit, function));
}
});
}
示例3: runTransaction
import com.google.firebase.database.Transaction; //导入方法依赖的package包/类
/**
* @param ref
* @param function
* @return
*/
@NonNull
@CheckReturnValue
public static Single<DataSnapshot> runTransaction(
@NonNull final DatabaseReference ref,
@NonNull final Function<MutableData, Transaction.Result> function) {
return RxValue.transaction(ref, function);
}
示例4: RunTransactionOnSubscribe
import com.google.firebase.database.Transaction; //导入方法依赖的package包/类
RunTransactionOnSubscribe(DatabaseReference ref, boolean fireLocalEvents,
Function<MutableData, Transaction.Result> task) {
this.ref = ref;
this.fireLocalEvents = fireLocalEvents;
this.task = task;
}
示例5: runTransaction
import com.google.firebase.database.Transaction; //导入方法依赖的package包/类
/**
* @see DatabaseReference#runTransaction(Transaction.Handler)
*/
@NonNull @CheckResult public static Completable runTransaction(@NonNull DatabaseReference ref,
@NonNull Function<MutableData, Transaction.Result> task) {
return runTransaction(ref, true, task);
}