core/src/main/java/net/typedrest/PollingEndpointImpl.java
StoppableObservable<TEntity> getObservable(Scheduler scheduler) {
        return runAsync(scheduler, (rx.Observer<? super TEntity> observer, Subscription subscription) -> {
            TEntity previousEntity;
            try {
                previousEntity = read();
            } catch (IOException | IllegalArgumentException | IllegalAccessException ex) {
                observer.onError(ex);
                return;
            }
            observer.onNext(previousEntity);

            while (endCondition == null || !endCondition.test(previousEntity)) {
                try {
                    sleep(pollingInterval * 1000);
                } catch (InterruptedException ex) {
                }
                if (subscription.isUnsubscribed()) {
                    break;
                }

                TEntity newEntity;
                try {
                    newEntity = read();
                } catch (IOException | IllegalArgumentException | IllegalAccessException ex) {
                    observer.onError(ex);
                    return;
                }
                if (!newEntity.equals(previousEntity)) {
                    observer.onNext(newEntity);
                }

                previousEntity = newEntity;
            }
            observer.onCompleted();
        });
    }
StoppableObservable<TEntity> getObservable(Scheduler scheduler) {
        return runAsync(scheduler, (rx.Observer<? super TEntity> observer, Subscription subscription) -> {
            TEntity previousEntity;
            try {
                previousEntity = read();
            } catch (IOException | IllegalArgumentException | IllegalAccessException ex) {
                observer.onError(ex);
                return;
            }
            observer.onNext(previousEntity);

            while (endCondition == null || !endCondition.test(previousEntity)) {
                try {
                    sleep(pollingInterval * 1000);
                } catch (InterruptedException ex) {
                }
                if (subscription.isUnsubscribed()) {
                    break;
                }

                TEntity newEntity;
                try {
                    newEntity = read();
                } catch (IOException | IllegalArgumentException | IllegalAccessException ex) {
                    observer.onError(ex);
                    return;
                }
                if (!newEntity.equals(previousEntity)) {
                    observer.onNext(newEntity);
                }

                previousEntity = newEntity;
            }
            observer.onCompleted();
        });
    }
Provides an observable stream of element states. Compares entities using
{@link Object#equals(java.lang.Object)} to detect changes.

@param pollingInterval The interval in milliseconds in which to send
requests to the server.
@param endCondition An optional predicate determining which entity state
ends the polling process.
@param scheduler The scheduler used to run the background thread.
@return An observable stream of element states.