I have this code base where I set the value. In offline mode, it is written successfully, but does not call the completion function of the call CompletionListener.onComplete.
newOrderRef.setValue(order, (firebaseError, firebase) -> { if (firebaseError != null) { Timber.e(firebaseError.toException(), "Order create failed, id: %s", order.getOrderId()); subscriber.onError(firebaseError.toException()); } else { Timber.i("Order created, id: %s", order.getOrderId()); newOrderRef.setPriority(0 - timestamp); subscriber.onNext(firebase.getKey()); subscriber.onCompleted(); } });
The callback is never called. But he writes beautifully.
In another case, even after canceling the subscription to onDestroy using CompositeSubscription , the subscriber is called when the value is written to the firebase server, even if the fragment is not running.
Is this the right behavior?
Subscription orderSubscription = OrderManager.createOrder(order) .subscribe(s -> { fabShowSuccess(); showSnackbar("onnext Order created " + order.getOrderId()); }, throwable -> { showSnackbar("Order failed. Make sure your are connected to internet."); fabShowFailed(); }, () -> { fabShowSuccess(); showSnackbar("Order created " + order.getOrderId()); }); mCompositeSubscription.add(orderSubscription);
In onDestroy() I call mCompositeSubscription.unsubscribe(); but the caller receives the call later.
Arka source share