@@ -467,6 +467,29 @@ public void onRequestResult(String optErrorCode, String optErrorMessage) {
467
467
this .rerunTransactions (affectedPath );
468
468
}
469
469
470
+ /**
471
+ * The purpose of `getValue` is to return the latest known value satisfying `query`.
472
+ *
473
+ * <p>If the client is connected, this method will send a request to the server. If the client is
474
+ * not connected, then either:
475
+ *
476
+ * <p>1. The client was once connected, but not anymore. 2. The client has never connected, this
477
+ * is the first operation this repo is handling.
478
+ *
479
+ * <p>In case (1), it's possible that the client still has an active listener, with cached data.
480
+ * Since this is the latest known value satisfying the query, that's what getValue will return. If
481
+ * there is no cached data, `getValue` surfaces an "offline" error.
482
+ *
483
+ * <p>In case (2), `getValue` will trigger a time-limited connection attempt. If the client is
484
+ * unable to connect to the server, the will surface an "offline" error because there cannot be
485
+ * any cached data. On the other hand, if the client is able to connect, `getValue` will return
486
+ * the server's value for the query, if one exists.
487
+ *
488
+ * <p>`getValue` updates the client's persistence cache whenever it's able to retrieve a new
489
+ * server value. It does this by installing a short-lived tracked query.
490
+ *
491
+ * @param query - The query to surface a value for.
492
+ */
470
493
public Task <DataSnapshot > getValue (Query query ) {
471
494
TaskCompletionSource <DataSnapshot > source = new TaskCompletionSource <>();
472
495
this .scheduleNow (
0 commit comments