Last active
April 2, 2018 14:36
-
-
Save sockeqwe/9ff1b611f8e41dea1930b73a67260ff5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FooActivity extends MviActivity<...> { | |
@Inject FooPresenter | |
public void onCreate(Bundle bundle){ | |
super.onCreate(bundle); | |
FooComponent component = DaggerFooComponent.builder() | |
.fooModule(new FooModule(bundle)) | |
.build(); | |
component.inject(this); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
class FooModule { | |
private Bundle bundle; | |
public FooModule(Bundle bundle){ | |
this.bundle = bundle; | |
} | |
@Provides | |
public FooPresenter provideFooPresenter(FooStateReducer stateReducer){ | |
return FooPresenter(stateReducer); | |
} | |
@Provides | |
public FooStateReducer provideFooStateReducer(){ | |
State initialState; | |
if (bunlde == null) { | |
initialState = new LoadingState(); | |
} else { | |
initialState = bundle.getParcelable("StateKey"); | |
} | |
return new FooStateReducer(initialState); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment