public class

SimpleDataSource

extends AbstractDataSource<T>
java.lang.Object
   ↳ com.facebook.datasource.AbstractDataSource<T>
     ↳ com.facebook.datasource.SimpleDataSource<T>

Class Overview

Settable DataSource.

Summary

Public Methods
static <T> SimpleDataSource<T> create()
Creates a new SimpleDataSource.
boolean setFailure(Throwable throwable)
Sets the failure.
boolean setProgress(float progress)
Sets the progress.
boolean setResult(T value)
Sets the value as the last result.
boolean setResult(T value, boolean isLast, Map<String, Object> extras)
Sets the result to value.
[Expand]
Inherited Methods
From class com.facebook.datasource.AbstractDataSource
From class java.lang.Object
From interface com.facebook.datasource.DataSource

Public Methods

public static SimpleDataSource<T> create ()

Creates a new SimpleDataSource.

public boolean setFailure (Throwable throwable)

Sets the failure.

This method will return true if the failure was successfully set, or false if the data source has already been set, failed or closed.

If the failure was successfully set, state of the data source will be set to AbstractDataSource.DataSourceStatus#FAILURE.

This will also notify the subscribers if the failure was successfully set.

Parameters
throwable the failure cause to be set.
Returns
  • true if the failure was successfully set.

public boolean setProgress (float progress)

Sets the progress.

Parameters
progress the progress in range [0, 1] to be set.
Returns
  • true if the progress was successfully set.

public boolean setResult (T value)

Sets the value as the last result.

See setResult(T, boolean).

public boolean setResult (T value, boolean isLast, Map<String, Object> extras)

Sets the result to value.

This method will return true if the value was successfully set, or false if the data source has already been set, failed or closed.

If the value was successfully set and isLast is true, state of the data source will be set to AbstractDataSource.DataSourceStatus#SUCCESS.

This will also notify the subscribers if the value was successfully set.

Parameters
value the value to be set
isLast whether or not the value is last.
extras an object with extra data for this datasource
Returns
  • true if the value was successfully set.