com.stanfy.enroscar.async.Async Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of enroscar-content Show documentation
Show all versions of enroscar-content Show documentation
Helper classes and extended abstractions for Android loaders, content resolvers, and DB access.
package com.stanfy.enroscar.async;
/**
* Represents some asynchronous operation that can observed and/or canceled.
* It's a bit similar to {@link java.util.concurrent.Future}. But instead of {@code get()} it has
* {@link #subscribe(AsyncObserver)}.
* After {@link #cancel()} is called observer methods won't be called.
*
*
* Asynchronous operation that provides the result is triggered (meaning actually executed)
* not sooner than the first {@link #subscribe(AsyncObserver)} call is performed.
* If {@link #cancel()} is called before the first {@link #subscribe(AsyncObserver)} invocation,
* the operations is never executed, and {@code subscribe()} is no-op.
*
*
*
* Implementations should not keep strong references to {@code Activity}s since they can be
* retained during Activity recreation.
*
*
* @param data type
* @author Roman Mazur - Stanfy (http://stanfy.com)
*/
public interface Async {
void subscribe(AsyncObserver observer);
void cancel();
}