Package com.mongodb.async.client
Class Observables
- java.lang.Object
-
- com.mongodb.async.client.Observables
-
@Deprecated public final class Observables extends Object
Deprecated.Prefer the Reactive Streams-based asynchronous driver (mongodb-driver-reactivestreams artifactId)Observable helpers.Allows async methods to be converted into event-based
Observable
s.- Since:
- 3.1
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <TResult> Observable<TResult>
observe(MongoIterable<TResult> mongoIterable)
Deprecated.Convert aMongoIterable
into anObservable
.static <TResult> Observable<TResult>
observe(Block<SingleResultCallback<TResult>> operation)
Deprecated.Allows the conversion ofSingleResultCallback
based operations into anObservable
static <TResult> Observable<TResult>
observeAndFlatten(Block<SingleResultCallback<List<TResult>>> operation)
Deprecated.Allows the conversion ofSingleResultCallback
based operations and flattens the results in anObservable
.
-
-
-
Method Detail
-
observe
public static <TResult> Observable<TResult> observe(MongoIterable<TResult> mongoIterable)
Deprecated.Convert aMongoIterable
into anObservable
.- Type Parameters:
TResult
- The type of result being observed- Parameters:
mongoIterable
- the MongoIterable to subscribe to- Returns:
- the observable version of the mongoIterable
-
observe
public static <TResult> Observable<TResult> observe(Block<SingleResultCallback<TResult>> operation)
Deprecated.Allows the conversion ofSingleResultCallback
based operations into anObservable
Requires a
Block
that is passed the callback to be used with the operation. This is required to make sure that the operation only occurs once theSubscription
signals for data.A typical example would be when wrapping callback based methods to make them observable.
For example, convertingMongoCollection.count(SingleResultCallback)
into anObservable
:Observable<Long> countObservable = observe(new Block<SingleResultCallback<Long>>() { public void apply(final SingleResultCallback<Long> callback) { collection.countDocuments(callback); } });
- Type Parameters:
TResult
- The type of result being observed- Parameters:
operation
- the block that implements the operation.- Returns:
- the observable version of the callback based operation
-
observeAndFlatten
public static <TResult> Observable<TResult> observeAndFlatten(Block<SingleResultCallback<List<TResult>>> operation)
Deprecated.Allows the conversion ofSingleResultCallback
based operations and flattens the results in anObservable
.Requires a
Block
that is passed the callback to be used with the operation. This is required to make sure that the operation only occurs once theSubscription
signals for data.- Type Parameters:
TResult
- The type of result being observed- Parameters:
operation
- the operation that is passed a callback and is used to delay execution of an operation until demanded.- Returns:
- a subscription
-
-