package com.malpo.sliver.sample.ui.number;

import com.malpo.sliver.sample.models.Number;

import timber.log.Timber;

class NumberPresenter implements NumberContract.Presenter {

    private NumberContract.View view;

    private NumberContract.Interactor interactor;

    private NumberMapper mapper;

    NumberPresenter(NumberContract.Interactor interactor) {
        this.interactor = interactor;
        this.mapper = new NumberMapper();
    }

    @Override
    public void setView(NumberContract.View view) {
        this.view = view;
    }

    @Override
    public void setupView() {
        //TODO Figure out how to unsubscribe
        interactor.getNumber().subscribe(this::displayNumber);
        interactor.onNumberUpdated().subscribe(this::onNumberUpdated);
    }

    @Override
    public void onNumberUpdated(Number number) {
        Timber.d("Number updated to: %d", number.value);
        displayNumber(number);
    }

    @Override
    public void incrementNumberBy10() {
        Timber.d("Incrementing number by 10");
        interactor.incrementNumberBy(10);
    }

    private void displayNumber(Number number) {
        view.display(mapper.map(number));
    }
}

@@ -678,29 +678,31 @@
 e(this::
-displayNumber
+onNumberUpdated
 );%0A     
@@ -906,29 +906,39 @@
     
+view.
 display
-Number
+(mapper.map
 (number)
 ;%0A  
@@ -933,16 +933,17 @@
 (number)
+)
 ;%0A    %7D%0A
@@ -1044,16 +1044,16 @@
 y 10%22);%0A
+
         
@@ -1095,104 +1095,7 @@
    %7D
-%0A%0A    private void displayNumber(Number number) %7B%0A        view.display(mapper.map(number));%0A    %7D
 %0A%7D%0A

Use Overriden, not private method to interact with presenter