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


Java CompletableEmitter类代码示例

本文整理汇总了Java中io.reactivex.CompletableEmitter的典型用法代码示例。如果您正苦于以下问题:Java CompletableEmitter类的具体用法?Java CompletableEmitter怎么用?Java CompletableEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: userlessAuthentication

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
public static Completable userlessAuthentication(
        final RedditClient reddit,
        final Credentials credentials) {
    return Completable.create(new CompletableOnSubscribe() {
        @Override
        public void subscribe(CompletableEmitter e) throws Exception {
            try {
                OAuthData oAuthData = reddit.getOAuthHelper().easyAuth(credentials);
                reddit.authenticate(oAuthData);
                e.onComplete();
            } catch (Exception ex) {
                e.onError(ex);
            }
        }
    });
}
 
开发者ID:jorgegil96,项目名称:JRAW-Android-Sample,代码行数:17,代码来源:RedditService.java

示例2: userAuthentication

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
public static Completable userAuthentication(
        final RedditClient reddit,
        final Credentials credentials,
        final String url) {
    return Completable.create(new CompletableOnSubscribe() {
        @Override
        public void subscribe(CompletableEmitter e) throws Exception {
            OAuthHelper oAuthHelper = reddit.getOAuthHelper();

            try {
                OAuthData oAuthData = oAuthHelper.onUserChallenge(url, credentials);
                reddit.authenticate(oAuthData);
                AuthenticationManager.get().onAuthenticated(oAuthData);
                e.onComplete();
            } catch (Exception ex) {
                e.onError(ex);
            }
        }
    });
}
 
开发者ID:jorgegil96,项目名称:JRAW-Android-Sample,代码行数:21,代码来源:RedditService.java

示例3: logout

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
public static Completable logout(final Credentials credentials) {
    return Completable.create(new CompletableOnSubscribe() {
        @Override
        public void subscribe(CompletableEmitter e) throws Exception {
            try {
                AuthenticationManager.get().getRedditClient().getOAuthHelper()
                        .revokeAccessToken(credentials);
                AuthenticationManager.get().getRedditClient().getOAuthHelper()
                        .revokeRefreshToken(credentials);
                // Calling deauthenticate() isn't really necessary, since revokeAccessToken()
                // already calls it.
                // AuthenticationManager.get().getRedditClient().deauthenticate();

                // As of JRAW 9.0.0, revoking the access/refresh token does not update the
                // auth state to NONE (it instead remains as NEEDS_REFRESH), so to completely
                // restart the session to a blank state you should re-instantiate the
                // AuthenticationManager. See https://github.com/mattbdean/JRAW/issues/196

                // AuthenticationManager.get().init(...., ....); uncomment this line.
                e.onComplete();
            } catch (Exception ex) {
                e.onError(ex);
            }
        }
    });
}
 
开发者ID:jorgegil96,项目名称:JRAW-Android-Sample,代码行数:27,代码来源:RedditService.java

示例4: deleteProfile

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
@Override
public Completable deleteProfile(final String uid) {
    return Completable.create(
            new CompletableOnSubscribe() {
                @Override
                public void subscribe(final CompletableEmitter e) throws Exception {
                    final DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
                    rootRef.child(USER_PROFILES)
                            .child(uid)
                            .setValue(null)
                            .addOnCompleteListener(new OnCompleteListener<Void>() {
                                @Override
                                public void onComplete(@NonNull Task<Void> task) {
                                    if (task.isSuccessful()) {
                                        e.onComplete();
                                    } else {
                                        e.onError(task.getException());
                                    }
                                }
                            });
                }

            });
}
 
开发者ID:BracketCove,项目名称:Profiler,代码行数:25,代码来源:FirebaseDatabaseService.java

示例5: updateProfile

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
@Override
public Completable updateProfile(final Profile profile) {
    return Completable.create(
            new CompletableOnSubscribe() {
                @Override
                public void subscribe(final CompletableEmitter e) throws Exception {
                    final DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
                    rootRef.child(USER_PROFILES)
                            .child(profile.getUid())
                            .setValue(profile)
                            .addOnCompleteListener(new OnCompleteListener<Void>() {
                                @Override
                                public void onComplete(@NonNull Task<Void> task) {
                                    if (task.isSuccessful()) {
                                        e.onComplete();
                                    } else {
                                        e.onError(task.getException());
                                    }
                                }
                            });
                }

            });
}
 
开发者ID:BracketCove,项目名称:Profiler,代码行数:25,代码来源:FirebaseDatabaseService.java

示例6: createAccount

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
@Override
public Completable createAccount(final Credentials cred) {
    return Completable.create(new CompletableOnSubscribe() {
        @Override
        public void subscribe(final CompletableEmitter e) throws Exception {
            if (auth == null) {
                auth = FirebaseAuth.getInstance();
            }

            auth.createUserWithEmailAndPassword(cred.getEmail(), cred.getPassword())
                    .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {
                            if (task.isSuccessful()) {
                                e.onComplete();
                            } else {
                                e.onError(task.getException());
                            }
                        }
                    });

        }
    });
}
 
开发者ID:BracketCove,项目名称:Profiler,代码行数:25,代码来源:FirebaseAuthService.java

示例7: attemptLogin

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
@Override
public Completable attemptLogin(final Credentials cred) {
    return Completable.create(new CompletableOnSubscribe() {
        @Override
        public void subscribe(final CompletableEmitter e) throws Exception {
            if (auth == null) {
                auth = FirebaseAuth.getInstance();
            }

            auth.signInWithEmailAndPassword(cred.getEmail(), cred.getPassword())
                    .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {
                            if (task.isSuccessful()) {
                                e.onComplete();
                            } else {
                                e.onError(task.getException());
                            }
                        }
                    });
        }
    });
}
 
开发者ID:BracketCove,项目名称:Profiler,代码行数:24,代码来源:FirebaseAuthService.java

示例8: deleteUser

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
@Override
public Completable deleteUser() {
    return Completable.create(new CompletableOnSubscribe() {
        @Override
        public void subscribe(final CompletableEmitter e) throws Exception {
            if (auth == null) {
                auth = FirebaseAuth.getInstance();
            }

            final FirebaseUser user = auth.getCurrentUser();

            user.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if (task.isSuccessful()) {
                        e.onComplete();
                    } else {
                        e.onError(task.getException());
                    }
                }
            });

        }
    });
}
 
开发者ID:BracketCove,项目名称:Profiler,代码行数:26,代码来源:FirebaseAuthService.java

示例9: setValue

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
/**
 * Set the given value on the specified {@link DatabaseReference}.
 *
 * @param ref reference represents a particular location in your database.
 * @param value value to update.
 * @return a {@link Completable} which is complete when the set value call finish successfully.
 */
@NonNull
public static Completable setValue(@NonNull final DatabaseReference ref,
                                   final Object value) {
   return Completable.create(new CompletableOnSubscribe() {
      @Override
      public void subscribe(@io.reactivex.annotations.NonNull final CompletableEmitter e) throws Exception {
         ref.setValue(value).addOnSuccessListener(new OnSuccessListener<Void>() {
            @Override public void onSuccess(Void aVoid) {
               e.onComplete();
            }
         }).addOnFailureListener(new OnFailureListener() {
            @Override public void onFailure(@NonNull Exception exception) {
               e.onError(exception);
            }
         });
      }
   });
}
 
开发者ID:DVT,项目名称:showcase-android,代码行数:26,代码来源:RxFirebaseDatabase.java

示例10: updateChildren

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
/**
 * Update the specific child keys to the specified values.
 *
 * @param ref        reference represents a particular location in your database.
 * @param updateData The paths to update and their new values
 * @return a {@link Completable} which is complete when the update children call finish successfully.
 */
@NonNull
public static Completable updateChildren(@NonNull final DatabaseReference ref,
                                         @NonNull final Map<String, Object> updateData) {
   return Completable.create(new CompletableOnSubscribe() {
      @Override
      public void subscribe(final CompletableEmitter emitter) throws Exception {
         ref.updateChildren(updateData, new DatabaseReference.CompletionListener() {
            @Override
            public void onComplete(DatabaseError error, DatabaseReference databaseReference) {
               if (error != null) {
                  emitter.onError(new RxFirebaseDataException(error));
               } else {
                  emitter.onComplete();
               }
            }
         });
      }
   });
}
 
开发者ID:DVT,项目名称:showcase-android,代码行数:27,代码来源:RxFirebaseDatabase.java

示例11: subscribe

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {

    final OnCompleteListener<T> listener = new OnCompleteListener<T>() {
        @Override
        public void onComplete(@NonNull Task<T> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    database.runTransaction(transaction).addOnCompleteListener(listener);
}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:21,代码来源:RunTransactionOnSubscribe.java

示例12: subscribe

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
    final OnCompleteListener<Void> listener = new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    batch.commit().addOnCompleteListener(listener);
}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:20,代码来源:CommitBatchOnSubscribe.java

示例13: subscribe

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
    final OnCompleteListener<Void> listener = new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    reference.set(value).addOnCompleteListener(listener);

}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:21,代码来源:SetOnSubscribe.java

示例14: subscribe

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
    final OnCompleteListener<Void> listener = new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    reference.delete().addOnCompleteListener(listener);
}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:20,代码来源:DeleteOnSubscribe.java

示例15: subscribe

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
    final OnCompleteListener<DocumentReference> listener =
            new OnCompleteListener<DocumentReference>() {
                @Override
                public void onComplete(@NonNull Task<DocumentReference> task) {

                    if (!emitter.isDisposed()) {
                        if (!task.isSuccessful()) {
                            emitter.onError(task.getException());
                        } else {
                            emitter.onComplete();
                        }
                    }

                }
            };

    reference.add(value).addOnCompleteListener(listener);
}
 
开发者ID:btrautmann,项目名称:RxFirestore,代码行数:21,代码来源:AddOnSubscribe.java


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