2828import java .util .Map ;
2929import java .util .concurrent .Executor ;
3030
31+ import durdinapps .rxfirebase2 .exceptions .RxFirebaseNullDataException ;
3132import io .reactivex .BackpressureStrategy ;
3233import io .reactivex .Completable ;
3334import io .reactivex .CompletableEmitter ;
@@ -133,6 +134,10 @@ public void subscribe(final SingleEmitter<DocumentReference> emitter) {
133134 ref .add (data ).addOnCompleteListener (new OnCompleteListener <DocumentReference >() {
134135 @ Override
135136 public void onComplete (@ NonNull Task <DocumentReference > task ) {
137+ if (task .getResult () == null ){
138+ emitter .onError (new RxFirebaseNullDataException (task .getException ()));
139+ return ;
140+ }
136141 emitter .onSuccess (task .getResult ());
137142 }
138143 }).addOnFailureListener (new OnFailureListener () {
@@ -162,6 +167,10 @@ public void subscribe(final SingleEmitter<DocumentReference> emitter) {
162167 ref .add (pojo ).addOnCompleteListener (new OnCompleteListener <DocumentReference >() {
163168 @ Override
164169 public void onComplete (@ NonNull Task <DocumentReference > task ) {
170+ if (task .getResult () == null ){
171+ emitter .onError (new RxFirebaseNullDataException (task .getException ()));
172+ return ;
173+ }
165174 emitter .onSuccess (task .getResult ());
166175 }
167176 }).addOnFailureListener (new OnFailureListener () {
@@ -186,7 +195,7 @@ public void onFailure(@NonNull Exception e) {
186195 * @return a Single which emits the {@link DocumentReference} of the added Document.
187196 */
188197 @ NonNull
189- private static Completable addDocumentOffline (@ NonNull final CollectionReference ref ,
198+ public static Completable addDocumentOffline (@ NonNull final CollectionReference ref ,
190199 @ NonNull final Map <String , Object > data ) {
191200 return Completable .create (new CompletableOnSubscribe () {
192201 @ Override
@@ -212,7 +221,7 @@ public void subscribe(CompletableEmitter emitter) {
212221 * @return a Single which emits the {@link DocumentReference} of the added Document.
213222 */
214223 @ NonNull
215- private static Completable addDocumentOffline (@ NonNull final CollectionReference ref ,
224+ public static Completable addDocumentOffline (@ NonNull final CollectionReference ref ,
216225 @ NonNull final Object pojo ) {
217226 return Completable .create (new CompletableOnSubscribe () {
218227 @ Override
@@ -1232,7 +1241,7 @@ public static <T> Maybe<List<T>> getCollection(@NonNull final CollectionReferenc
12321241 * @param mapper specific function to map the dispatched events.
12331242 */
12341243 @ NonNull
1235- private static <T > Maybe <List <T >> getCollection (CollectionReference ref ,
1244+ public static <T > Maybe <List <T >> getCollection (CollectionReference ref ,
12361245 DocumentSnapshotMapper <QuerySnapshot ,
12371246 List <T >> mapper ) {
12381247 return getCollection (ref )
@@ -1259,7 +1268,7 @@ public static <T> Maybe<List<T>> getCollection(@NonNull final Query query,
12591268 * @param mapper specific function to map the dispatched events.
12601269 */
12611270 @ NonNull
1262- private static <T > Maybe <List <T >> getCollection (@ NonNull Query query ,
1271+ public static <T > Maybe <List <T >> getCollection (@ NonNull Query query ,
12631272 @ NonNull DocumentSnapshotMapper <QuerySnapshot ,
12641273 List <T >> mapper ) {
12651274 return getCollection (query )
0 commit comments