public abstract class

BaseDataSubscriber

extends Object
implements DataSubscriber<T>
java.lang.Object
   ↳ com.facebook.datasource.BaseDataSubscriber<T>
Known Direct Subclasses

Class Overview

Base implementation of DataSubscriber that ensures that the data source is closed when the subscriber has finished with it.

Sample usage:

 
 dataSource.subscribe(
   new BaseDataSubscriber() {
     @Override
     public void onNewResultImpl(DataSource dataSource) {
       // Store image ref to be released later.
       mCloseableImageRef = dataSource.getResult();
       // Use the image.
       updateImage(mCloseableImageRef);
       // No need to do any cleanup of the data source.
     }

     @Override
     public void onFailureImpl(DataSource dataSource) {
       // No cleanup of the data source required here.
     }
   });
 
 

Summary

Public Constructors
BaseDataSubscriber()
Public Methods
void onCancellation(DataSource<T> dataSource)
Called whenever the request is cancelled (a request being cancelled means that is was closed before it finished).
void onFailure(DataSource<T> dataSource)
Called whenever an error occurs inside of the pipeline.
void onNewResult(DataSource<T> dataSource)
Called whenever a new value is ready to be retrieved from the DataSource.
void onProgressUpdate(DataSource<T> dataSource)
Called when the progress updates.
Protected Methods
abstract void onFailureImpl(DataSource<T> dataSource)
abstract void onNewResultImpl(DataSource<T> dataSource)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.facebook.datasource.DataSubscriber

Public Constructors

public BaseDataSubscriber ()

Public Methods

public void onCancellation (DataSource<T> dataSource)

Called whenever the request is cancelled (a request being cancelled means that is was closed before it finished).

No further results will be produced after this method is called.

public void onFailure (DataSource<T> dataSource)

Called whenever an error occurs inside of the pipeline.

No further results will be produced after this method is called.

The throwable resulting from the failure can be obtained using dataSource.getFailureCause.

public void onNewResult (DataSource<T> dataSource)

Called whenever a new value is ready to be retrieved from the DataSource.

To retrieve the new value, call dataSource.getResult().

To determine if the new value is the last, use dataSource.isFinished().

public void onProgressUpdate (DataSource<T> dataSource)

Called when the progress updates.

Protected Methods

protected abstract void onFailureImpl (DataSource<T> dataSource)

protected abstract void onNewResultImpl (DataSource<T> dataSource)