Skip to content

Commit fdd840c

Browse files
authored
Update README.md
1 parent bf6d3b0 commit fdd840c

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,34 @@
1111
![badge][badge-wasm]
1212

1313

14-
Documentation to come.
14+
Write concise multiplatform presenter functions with presenter-middleware:
15+
16+
```
17+
interface StartView : GameBaseView {
18+
fun showLoading()
19+
fun hideLoading()
20+
fun showError(msg: String)
21+
22+
override fun presenter(): Presenter<View, AppState> = startPresenter
23+
}
24+
25+
val startPresenter = presenter<StartView> {
26+
{
27+
select { state.isLoadingItems } then {
28+
if (state.isLoadingItems) {
29+
showLoading()
30+
} else {
31+
hideLoading()
32+
}
33+
}
34+
35+
select { state.errorLoadingItems } then { showError(state.errorMsg) }
36+
}
37+
}
38+
39+
```
40+
Presenter-middleware handles wiring this up to your view and store subscriptions. Just implement the interface on Android and iOS and dispatch lifecycle events. See the [ReadingList sample app](https://github.com/reduxkotlin/ReadingListSampleApp) or the [Name Game Sample App](https://github.com/reduxkotlin/NameGameSampleApp) for example usage.
1541

16-
Example usage:
1742

1843

1944
__How to add to project:__
@@ -31,6 +56,13 @@ kotlin {
3156
}
3257
```
3358

59+
Add the presetner store-enhancer:
60+
```
61+
val appStore = createStore(reducer, AppState.INITIAL_STATE,
62+
compose(listOf(presenterEnhancer(uiContext),
63+
applyMiddleware(createThunkMiddleware())
64+
```
65+
3466
For JVM only:
3567
```
3668
implementation "org.reduxkotlin:presenter-middleware-jvm:0.2.8"

0 commit comments

Comments
 (0)