• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CompletableEmitter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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.update(updates).addOnCompleteListener(listener);

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


示例17: listener

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
/**
 * @param emit
 * @param <R>
 * @return
 */
@NonNull
@CheckReturnValue
public static <R> OnCompleteListener<R> listener(@NonNull final CompletableEmitter emit) {
    return new OnCompleteListener<R>() {
        @Override
        public void onComplete(@NonNull final Task<R> task) {
            if (!emit.isDisposed()) {
                if (task.isSuccessful()) {
                    emit.onComplete();
                } else {
                    Exception e = task.getException();
                    emit.onError(e != null ? e : new RuntimeException());
                }
            }
        }
    };
}
 
开发者ID:yongjhih,项目名称:rxtasks,代码行数:23,代码来源:RxTask.java


示例18: listener

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
public static OnCompleteListener<Void> listener(@NonNull final CompletableEmitter emitter) {
  return new OnCompleteListener<Void>() {
    @Override public void onComplete(@NonNull Task<Void> task) {
      if (!task.isSuccessful()) {
        if (!emitter.isDisposed()) {
          emitter.onError(task.getException());
        }
        return;
      }

      if (!emitter.isDisposed()) {
        emitter.onComplete();
      }
    }
  };
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:17,代码来源:GmsTaskListeners.java


示例19: subscribe

import io.reactivex.CompletableEmitter; //导入依赖的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


示例20: buildCompleteable

import io.reactivex.CompletableEmitter; //导入依赖的package包/类
/**
 * Given an operation that takes a {@link MaybeConsumer<Success>}, create a JavaRX
 * {@link Completable} that succeeds iff the operation does.
 *
 * Example:
 * <pre>
 *     // update the experiment, and then log that it was successful
 *     DataController dc = getDataController();
 *     MaybeConsumers.buildCompleteable(mc -> dc.updateExperiment(e.getExperimentId(), mc))
 *                   .subscribe(() -> log("successfully updated!"));
 * </pre>
 */
public static Completable buildCompleteable(
        io.reactivex.functions.Consumer<MaybeConsumer<Success>> c) {
    return Completable.create(new CompletableOnSubscribe() {
        @Override
        public void subscribe(CompletableEmitter emitter) throws Exception {
            c.accept(new MaybeConsumer<Success>() {
                @Override
                public void success(Success value) {
                    emitter.onComplete();
                }

                @Override
                public void fail(Exception e) {
                    emitter.onError(e);
                }
            });
        }
    });
}
 
开发者ID:google,项目名称:science-journal,代码行数:32,代码来源:MaybeConsumers.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TypeMirror类代码示例发布时间:2022-05-21
下一篇:
Java QzoneShare类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap