Package com.mongodb.async.client
Class Observables
- java.lang.Object
-
- com.mongodb.async.client.Observables
-
Deprecated.Prefer the Reactive Streams-based asynchronous driver (mongodb-driver-reactivestreams artifactId)
@Deprecated public final class Observables extends Object
Observable helpers.Allows async methods to be converted into event-based
Observables.- 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 aMongoIterableinto anObservable.static <TResult> Observable<TResult>observe(Block<SingleResultCallback<TResult>> operation)Deprecated.Allows the conversion ofSingleResultCallbackbased operations into anObservablestatic <TResult> Observable<TResult>observeAndFlatten(Block<SingleResultCallback<List<TResult>>> operation)Deprecated.Allows the conversion ofSingleResultCallbackbased operations and flattens the results in anObservable.
-
-
-
Method Detail
-
observe
public static <TResult> Observable<TResult> observe(MongoIterable<TResult> mongoIterable)
Deprecated.Convert aMongoIterableinto 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 ofSingleResultCallbackbased operations into anObservableRequires a
Blockthat is passed the callback to be used with the operation. This is required to make sure that the operation only occurs once theSubscriptionsignals 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 ofSingleResultCallbackbased operations and flattens the results in anObservable.Requires a
Blockthat is passed the callback to be used with the operation. This is required to make sure that the operation only occurs once theSubscriptionsignals 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
-
-