public static < T > ServiceFuture < T > fromResponse ( final Observable < ServiceResponse < T > > observable , final ServiceCallback < T > callback ) { final ServiceFuture < T > serviceFuture = new ServiceFuture <> ( ) ; serviceFuture . subscription = observable . last ( ) . subscribe ( new Action1 < ServiceResponse < T > > ( ) { @ Override public void call ( ServiceResponse < T > t ) { if ( callback != null ) { callback . success ( t . body ( ) ) ; } serviceFuture . set ( t . body ( ) ) ; } } , new Action1 < Throwable > ( ) { @ Override public void call ( Throwable throwable ) { if ( callback != null ) { callback . failure ( throwable ) ; } serviceFuture . setException ( throwable ) ; } } ) ; return serviceFuture ; }
Creates a ServiceCall from an observable object and a callback .