konmik / nucleus

Nucleus is an Android library, which utilizes the Model-View-Presenter pattern to properly connect background tasks with visual parts of an application.
MIT License
1.98k stars 253 forks source link

Using restartableLatestCache, nothing being called #106

Closed Orbyt closed 8 years ago

Orbyt commented 8 years ago

Trying to get re-familiar with Nucleus again after a bit of an absence.

In my Presenters onCreate(), I have this restartableLatestCache():

restartableLatestCache(1,
                new Func0<Observable<LaunchResponse>>() {
                    @Override
                    public Observable<LaunchResponse> call() {
                        Log.d(TAG, "step one");
                        return launchService.getNextXLaunches(10)
                                .subscribeOn(Schedulers.io())
                                .observeOn(AndroidSchedulers.mainThread());
                    }
                },
                new Action2<LaunchFragment, LaunchResponse>() {
                    @Override
                    public void call(LaunchFragment fragment, LaunchResponse response) {
                        Log.d(TAG, "call: launches: " + response.getTotal());
                        fragment.addLaunchesToAdapter(response.getLaunches());
                    }
                },
                new Action2<LaunchFragment, Throwable>() {
                    @Override
                    public void call(LaunchFragment fragment, Throwable throwable) {
                        Log.d(TAG, "error in launch presenter");
                    }
                });

The issue is none of the Log.d() methods are being called, so nothing is being executed. Why is this?

gautamjain commented 8 years ago

You have to call start(1)

:)

konmik commented 8 years ago

@gautamjain thx! :)