StockResponseExtensions<T> extension

Useful StockResponse extensions.

on

Properties

isData bool

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Returns if the response is a StockResponseData
no setter
isError bool

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Returns if the response is a StockResponseError
no setter
isLoading bool

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Returns if the response is a StockResponseLoading
no setter

Methods

getDataOrNull() → T?

Available on StockResponse<T>, provided by the StockResponseExtensions extension

If there is data available, returns it; otherwise returns null.
map<E>({required E onLoading(StockResponseLoading<T> value), required E onData(StockResponseData<T> value), required E onError(StockResponseError<T> value)}) → E

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Invokes onData if the response is successful, onLoading if the response is loading, and onError if the response is an error.
mapData<E>(E onData(StockResponseData<T> value)) StockResponse<E>

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Invokes onData to transform the StockResponse
mapOrNull<E>({E onLoading(StockResponseLoading<T> value)?, E onData(StockResponseData<T> value)?, E onError(StockResponseError<T> value)?}) → E?

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Invokes onData if the response is successful, onLoading if the response is loading, and onError if the response is an error. If the callback is not provided, null is returned.
maybeMap<E>({required E orElse(), E onLoading(StockResponseLoading<T> value)?, E onData(StockResponseData<T> value)?, E onError(StockResponseError<T> value)?}) → E

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Invokes onData or orElse as fallback if the response is successful, onLoading or orElse as fallback if the response is loading, and onError or orElse as fallback if the response is an error.
maybeWhen<E>({required E orElse(ResponseOrigin origin), E onLoading(ResponseOrigin origin)?, E onData(ResponseOrigin origin, T data)?, E onError(ResponseOrigin origin, Object error, StackTrace? stackTrace)?}) → E

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Invokes onData or orElse as fallback if the response is successful, onLoading or orElse as fallback if the response is loading, and onError or orElse as fallback if the response is an error.
requireData() → T

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Returns the available data or throws error if there is no data.
requireError() Object

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Returns the available data or throws error if there is no data.
throwIfError() → void

Available on StockResponse<T>, provided by the StockResponseExtensions extension

If this StockResponse is of type StockResponseError, throws the exception. Otherwise, does nothing.
when<E>({required E onLoading(ResponseOrigin origin), required E onData(ResponseOrigin origin, T data), required E onError(ResponseOrigin origin, Object error, StackTrace? stackTrace)}) → E

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Invokes onData if the response is successful, onLoading if the response is loading, and onError if the response is an error.
whenOrNull<E>({E onLoading(ResponseOrigin origin)?, E onData(ResponseOrigin origin, T data)?, E onError(ResponseOrigin origin, Object error, StackTrace? stackTrace)?}) → E?

Available on StockResponse<T>, provided by the StockResponseExtensions extension

Invokes onData if the response is successful, onLoading if the response is loading, and onError if the response is an error. If the callback is not provided, null is returned.