All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mongodb.async.client.Observer Maven / Gradle / Ivy

There is a newer version: 3.12.14
Show newest version
/*
 * Copyright 2008-present MongoDB, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.mongodb.async.client;

/**
 * Provides a mechanism for receiving push-based notifications.
 *
 * 

* Will receive a call to {@link #onSubscribe(Subscription)} on subscription to the {@link Observable}. * No further notifications will be received until {@link Subscription#request(long)} is called. *

*

* After signaling demand: *

    *
  • One or more invocations of {@link #onNext(Object)} up to the maximum number defined by {@link Subscription#request(long)}
  • *
  • Single invocation of {@link #onError(Throwable)} or {@link Observer#onComplete()} which signals a terminal state after which no * further events will be sent.
  • *
*

* Demand can be signaled via {@link Subscription#request(long)} whenever the {@link Observer} instance is capable of handling more. *

* * @param The type of element signaled. * @since 3.1 * @deprecated Prefer the Reactive Streams-based asynchronous driver (mongodb-driver-reactivestreams artifactId) */ @Deprecated public interface Observer { /** * Invoked on subscription to an {@link Observable}. *

* No operation will happen until {@link Subscription#request(long)} is invoked. *

*

* It is the responsibility of this Subscriber instance to call {@link Subscription#request(long)} whenever more data is wanted. *

*

* The {@link MongoIterable} will send notifications only in response to {@link Subscription#request(long)}. *

* * @param subscription {@link Subscription} that allows requesting data via {@link Subscription#request(long)} */ void onSubscribe(Subscription subscription); /** * Provides the Observer with a new item to observe. *

* The Observer may call this method 0 or more times. *

*

* The {@link Observable} will not call this method again after it calls either {@link #onComplete} or * {@link #onError}. *

* * @param result the item emitted by the {@link Observable} */ void onNext(TResult result); /** * Notifies the Observer that the {@link Observable} has experienced an error condition. * *

If the {@link Observable} calls this method, it will not thereafter call {@link #onNext} or {@link #onComplete}.

* * @param e the exception encountered by the {@link Observable} */ void onError(Throwable e); /** * Notifies the Subscriber that the {@link Observable} has finished sending push-based notifications. *

* The {@link Observable} will not call this method if it calls {@link #onError}. *

*/ void onComplete(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy