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


Java Transaction.Handler方法代码示例

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


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

示例1: TransactionData

import com.google.firebase.database.Transaction; //导入方法依赖的package包/类
private TransactionData(
    Path path,
    Transaction.Handler handler,
    ValueEventListener outstandingListener,
    TransactionStatus status,
    boolean applyLocally,
    long order) {
  this.path = path;
  this.handler = handler;
  this.outstandingListener = outstandingListener;
  this.status = status;
  this.retryCount = 0;
  this.applyLocally = applyLocally;
  this.order = order;
  this.abortReason = null;
  this.currentInputSnapshot = null;
  this.currentOutputSnapshotRaw = null;
  this.currentOutputSnapshotResolved = null;
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:20,代码来源:Repo.java

示例2: 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);
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:26,代码来源:RunTransactionOnSubscribe.java

示例3: runTransactionOnComplete

import com.google.firebase.database.Transaction; //导入方法依赖的package包/类
private void runTransactionOnComplete(Transaction.Handler handler, DatabaseError error,
    boolean committed, DataSnapshot snapshot) {
  try {
    handler.onComplete(error, committed, snapshot);
  } catch (Exception e) {
    operationLogger.error("Exception in transaction onComplete callback", e);
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:9,代码来源:Repo.java

示例4: transaction

import com.google.firebase.database.Transaction; //导入方法依赖的package包/类
/**
 * @param emitter
 * @param function
 * @return
 */
@NonNull
@CheckReturnValue
public static Transaction.Handler transaction(
        @NonNull final SingleEmitter<DataSnapshot> emitter,
        @NonNull final Function<MutableData, Transaction.Result> function) {
    return new Transaction.Handler() {
        @Override
        public Transaction.Result doTransaction(MutableData mutableData) {
            try {
                return function.apply(mutableData);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public void onComplete(@Nullable DatabaseError databaseError,
                               boolean committed,
                               @NonNull DataSnapshot dataSnapshot) {
            if (!emitter.isDisposed()) {
                if (null == databaseError) {
                    emitter.onSuccess(dataSnapshot);
                } else {
                    emitter.onError(databaseError.toException());
                }
            }
        }
    };
}
 
开发者ID:yongjhih,项目名称:rxfirebase,代码行数:35,代码来源:RxValue.java


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