本文整理了Java中rx.Observable.unsafeCreate()
方法的一些代码示例,展示了Observable.unsafeCreate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.unsafeCreate()
方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:unsafeCreate
暂无
代码示例来源:origin: AsyncHttpClient/async-http-client
return Observable.unsafeCreate(new Observable.OnSubscribe<Response>() {
代码示例来源:origin: akarnokd/RxJava2Interop
/**
* Converts a Reactive-Streams Publisher of any kind (the base type of 2.x Flowable)
* into an 1.x Observable, composing the backpressure and cancellation
* (unsubscription) through.
* <p>
* Note that this method can convert <strong>any</strong> Reactive-Streams compliant
* source into an 1.x Observable, not just the 2.x Flowable.
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator doesn't interfere with backpressure which is determined by the
* source {@code Publisher}'s backpressure behavior.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>The method does not operate by default on a particular {@code Scheduler}.</dd>
* </dl>
* @param <T> the value type
* @param source the source Reactive-Streams Publisher instance, not null
* @return the new 1.x Observable instance
* @throws NullPointerException if {@code source} is null
*/
@io.reactivex.annotations.SchedulerSupport(io.reactivex.annotations.SchedulerSupport.NONE)
public static <T> rx.Observable<T> toV1Observable(org.reactivestreams.Publisher<T> source) {
io.reactivex.internal.functions.ObjectHelper.requireNonNull(source, "source is null");
return rx.Observable.unsafeCreate(new FlowableV2ToObservableV1<T>(source));
}
代码示例来源:origin: davidmoten/rtree
/**
* <p>
* Returns an Observable sequence of {@link Entry} that satisfy the given
* condition. Note that this method is well-behaved only if:
*
*
* <p>
* {@code condition(g)} is true for {@link Geometry} g implies
* {@code condition(r)} is true for the minimum bounding rectangles of the
* ancestor nodes.
*
* <p>
* {@code distance(g) < D} is an example of such a condition.
*
*
* @param condition
* return Entries whose geometry satisfies the given condition
* @return sequence of matching entries
*/
@VisibleForTesting
Observable<Entry<T, S>> search(Func1<? super Geometry, Boolean> condition) {
if (root.isPresent())
return Observable.unsafeCreate(new OnSubscribeSearch<T, S>(root.get(), condition));
else
return Observable.empty();
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void o1f2IgnoreCancel() {
toV2Flowable(rx.Observable.unsafeCreate(new OnSubscribe<Object>() {
@Override
public void call(Subscriber<? super Object> s) {
s.onNext(null);
s.onNext(1);
s.onError(new RuntimeException("Forced failure"));
s.onCompleted();
}
}))
.test()
.assertFailure(NullPointerException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void o1fo2IgnoreCancel() {
toV2Observable(rx.Observable.unsafeCreate(new OnSubscribe<Object>() {
@Override
public void call(Subscriber<? super Object> s) {
s.onNext(null);
s.onNext(1);
s.onError(new RuntimeException("Forced failure"));
s.onCompleted();
}
}))
.test()
.assertFailure(NullPointerException.class);
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<byte[]> getBytes(@NonNull final StorageReference storageRef,
final long maxDownloadSizeBytes) {
return Observable.unsafeCreate(new Observable.OnSubscribe<byte[]>() {
@Override
public void call(final Subscriber<? super byte[]> subscriber) {
RxTask.assignOnTask(subscriber, storageRef.getBytes(maxDownloadSizeBytes));
}
});
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<StorageMetadata> getMetadata(@NonNull final StorageReference storageRef) {
return Observable.unsafeCreate(new Observable.OnSubscribe<StorageMetadata>() {
@Override
public void call(final Subscriber<? super StorageMetadata> subscriber) {
RxTask.assignOnTask(subscriber, storageRef.getMetadata());
}
});
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<FileDownloadTask.TaskSnapshot> getFile(@NonNull final StorageReference storageRef,
@NonNull final File destinationFile) {
return Observable.unsafeCreate(new Observable.OnSubscribe<FileDownloadTask.TaskSnapshot>() {
@Override
public void call(final Subscriber<? super FileDownloadTask.TaskSnapshot> subscriber) {
RxTask.assignOnTask(subscriber, storageRef.getFile(destinationFile));
}
});
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<FileDownloadTask.TaskSnapshot> getFile(@NonNull final StorageReference storageRef,
@NonNull final Uri destinationUri) {
return Observable.unsafeCreate(new Observable.OnSubscribe<FileDownloadTask.TaskSnapshot>() {
@Override
public void call(final Subscriber<? super FileDownloadTask.TaskSnapshot> subscriber) {
RxTask.assignOnTask(subscriber, storageRef.getFile(destinationUri));
}
});
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<StorageMetadata> updateMetadata(@NonNull final StorageReference storageRef,
@NonNull final StorageMetadata metadata) {
return Observable.unsafeCreate(new Observable.OnSubscribe<StorageMetadata>() {
@Override
public void call(final Subscriber<? super StorageMetadata> subscriber) {
RxTask.assignOnTask(subscriber, storageRef.updateMetadata(metadata));
}
});
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<AuthResult> signInWithCredential(@NonNull final FirebaseAuth firebaseAuth,
@NonNull final AuthCredential credential) {
return Observable.unsafeCreate(new Observable.OnSubscribe<AuthResult>() {
@Override
public void call(final Subscriber<? super AuthResult> subscriber) {
RxTask.assignOnTask(subscriber, firebaseAuth.signInWithCredential(credential));
}
});
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<ProviderQueryResult> fetchProvidersForEmail(@NonNull final FirebaseAuth firebaseAuth,
@NonNull final String email) {
return Observable.unsafeCreate(new Observable.OnSubscribe<ProviderQueryResult>() {
@Override
public void call(final Subscriber<? super ProviderQueryResult> subscriber) {
RxTask.assignOnTask(subscriber, firebaseAuth.fetchProvidersForEmail(email));
}
});
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<Void> sendPasswordResetEmail(@NonNull final FirebaseAuth firebaseAuth,
@NonNull final String email) {
return Observable.unsafeCreate(new Observable.OnSubscribe<Void>() {
@Override
public void call(final Subscriber<? super Void> subscriber) {
RxTask.assignOnTask(subscriber, firebaseAuth.sendPasswordResetEmail(email));
}
});
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<HttpsCallableResult> getHttpsCallable(@NonNull final FirebaseFunctions functions,
@NonNull final String name,
@Nullable final Object data) {
return Observable.unsafeCreate(new Observable.OnSubscribe<HttpsCallableResult>() {
@Override
public void call(Subscriber<? super HttpsCallableResult> subscriber) {
RxTask.assignOnTask(subscriber, functions.getHttpsCallable(name).call(data));
}
});
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<AuthResult> signInWithEmailAndPassword(@NonNull final FirebaseAuth firebaseAuth,
@NonNull final String email,
@NonNull final String password) {
return Observable.unsafeCreate(new Observable.OnSubscribe<AuthResult>() {
@Override
public void call(final Subscriber<? super AuthResult> subscriber) {
RxTask.assignOnTask(subscriber, firebaseAuth.signInWithEmailAndPassword(email, password));
}
});
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<UploadTask.TaskSnapshot> putBytes(@NonNull final StorageReference storageRef,
@NonNull final byte[] bytes,
@NonNull final StorageMetadata metadata) {
return Observable.unsafeCreate(new Observable.OnSubscribe<UploadTask.TaskSnapshot>() {
@Override
public void call(final Subscriber<? super UploadTask.TaskSnapshot> subscriber) {
RxTask.assignOnTask(subscriber, storageRef.putBytes(bytes, metadata));
}
});
}
代码示例来源:origin: nmoskalenko/RxFirebase
@NonNull
public static Observable<UploadTask.TaskSnapshot> putStream(@NonNull final StorageReference storageRef,
@NonNull final InputStream stream,
@NonNull final StorageMetadata metadata) {
return Observable.unsafeCreate(new Observable.OnSubscribe<UploadTask.TaskSnapshot>() {
@Override
public void call(final Subscriber<? super UploadTask.TaskSnapshot> subscriber) {
RxTask.assignOnTask(subscriber, storageRef.putStream(stream, metadata));
}
});
}
代码示例来源:origin: davidmoten/rxjava-extras
@Override
public Observable<T> call(Observable<T> source) {
return Observable.unsafeCreate(new OnSubscribeMapLast<T>(source, function));
}
};
代码示例来源:origin: com.github.davidmoten/rxjava-extras
@Override
public Observable<T> call(Observable<T> o) {
return Observable.unsafeCreate(new OnSubscribeDoOnEmpty<T>(o, onEmpty));
}
};
代码示例来源:origin: avluis/Hentoid
Observable<File> create(final File rootDir) {
return Observable.unsafeCreate(subscriber -> {
File[] childDirs = rootDir.listFiles();
for (File child : childDirs) {
subscriber.onNext(child);
}
subscriber.onCompleted();
});
}
}
内容来源于网络,如有侵权,请联系作者删除!