How to make RxJava interval to perform action instantly : <p>Hello I am making observable to ask my server about its online/offline status every 15 seconds:</p>

<pre><code>public Observable&lt;Response&gt; repeatCheckServerStatus(int intervalSec, final String path) {
        return Observable.interval(intervalSec, TimeUnit.SECONDS)
                .flatMap(new Func1&lt;Long, Observable&lt;Response&gt;&gt;() {
                    @Override
                    public Observable&lt;Response&gt; call(Long aLong) {
                        return Observable.create(new Observable.OnSubscribe&lt;Response&gt;() {
                            @Override
                            public void call(Subscriber&lt;? super Response&gt; subscriber) {
                                try {
                                    Response response = client.newCall(new Request.Builder()
                                            .url(path + API_ACTION_CHECK_ONLINE_STATUS)
                                            .header("Content-Type", "application/x-www-form-urlencoded")
                                            .get()
                                            .build()).execute();

                                    subscriber.onNext(response);
                                    subscriber.onCompleted();
                                    if (!response.isSuccessful())
                                        subscriber.onError(new Exception());
                                } catch (Exception e) {
                                    subscriber.onError(e);
                                }
                            }
                        })
                                .subscribeOn(Schedulers.io())
                                .observeOn(AndroidSchedulers.mainThread());
                    }
                });

    }
</code></pre>

<p>After I call this method, first execution of code will be after intervalSec time (15sec in my case). Looking at rxJava docummentation of interval method:</p>

<p><a href="http://reactivex.io/documentation/operators/interval.html" rel="noreferrer">http://reactivex.io/documentation/operators/interval.html</a></p>

<p>This is how it should be. </p>

<p>Question: is there any way to execute code instantly and then repeat in intervals?</p>
