Interface DataTransformer<FROM,​TO>

  • Type Parameters:
    FROM - Data type this transformer receives
    TO - Type of transformed data

    public interface DataTransformer<FROM,​TO>
    Transforms or processes data before it is given to subscribed DataObservers. A transformer is set via SubscriptionBuilder.transform(DataTransformer).

    Note that a transformer is not required to actually "transform" any data. Technically, it's fine to return the same data it received and just do some processing with it.

    Threading notes: transformations are executed sequentially on a background thread owned by the subscription publisher. It is OK to perform long lasting operations, however this will block notifications to all other observers until finished.

    • Method Detail

      • transform

        TO transform​(FROM source)
              throws java.lang.Exception
        Transforms/processes the given data.
        Parameters:
        source - data to be transformed
        Returns:
        transformed data
        Throws:
        java.lang.Exception - Transformers may throw any exceptions, which can be reacted on via SubscriptionBuilder.onError(ErrorObserver).