Skip to content

Commit 24fc267

Browse files
author
Patrick Jackson
committed
[WIP] working without view type param for presenterMiddleware
1 parent 5f081a0 commit 24fc267

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

common/src/commonMain/kotlin/com/willowtreeapps/common/LibraryApp.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class LibraryApp(navigator: Navigator,
2222
createStore(combineReducers(reducer, navigationReducer), AppState.INITIAL_STATE, compose(listOf(
2323
presenterEnhancer,
2424
applyMiddleware(
25-
presenterMiddleware<AppState, ViewWithProvider>(uiContext),
25+
presenterMiddleware(uiContext),
2626
coroutineDispatcher(uiContext),
2727
loggerMiddleware,
2828
createThunkMiddleware(),

common/src/commonMain/kotlin/com/willowtreeapps/common/external/PresenterInjecter.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ val presenterEnhancer: StoreEnhancer = { storeCreator: StoreCreator ->
4949
* Attaching sets the presenter to the view.
5050
* PresenterFactory subscribes to changes in state, and passes state to presenters.
5151
*/
52-
fun <S : Any, V : ViewWithProvider> presenterMiddleware(uiContext: CoroutineContext): Middleware = { store ->
52+
fun presenterMiddleware(uiContext: CoroutineContext): Middleware = { store ->
5353

5454
val uiScope = CoroutineScope(uiContext)
55-
val subscribers = mutableMapOf<V, StoreSubscriberHolder>()
55+
val subscribers = mutableMapOf<ViewWithProvider, StoreSubscriberHolder>()
5656
var subscription: StoreSubscription? = null
5757
val coroutineScope = CoroutineScope(uiContext)
5858

@@ -68,7 +68,7 @@ fun <S : Any, V : ViewWithProvider> presenterMiddleware(uiContext: CoroutineCont
6868
}
6969
}
7070

71-
fun attachView(view: V) {
71+
fun attachView(view: ViewWithProvider) {
7272
Logger.d("AttachView: $view", Logger.Category.LIFECYCLE)
7373
// view.dispatch = store.dispatch
7474
//TODO is hanging onto subscription needed?
@@ -88,7 +88,7 @@ fun <S : Any, V : ViewWithProvider> presenterMiddleware(uiContext: CoroutineCont
8888
}
8989
}
9090

91-
fun detachView(view: V) {
91+
fun detachView(view: ViewWithProvider) {
9292
Logger.d("DetachView: $view", Logger.Category.LIFECYCLE)
9393
subscribers[view] = StoreSubscriberHolder(ViewLifecycle.DETACHED, subscribers[view]!!.subscriber)
9494
}
@@ -106,11 +106,11 @@ fun <S : Any, V : ViewWithProvider> presenterMiddleware(uiContext: CoroutineCont
106106
{ next: Dispatcher ->
107107
{ action: Any ->
108108
when (action) {
109-
is AttachView -> attachView(action.view as V)
109+
is AttachView -> attachView(action.view as ViewWithProvider)
110110

111-
is DetachView -> detachView(action.view as V)
111+
is DetachView -> detachView(action.view as ViewWithProvider)
112112

113-
is ClearView -> clearView(action.view as V)
113+
is ClearView -> clearView(action.view as ViewWithProvider)
114114

115115
else -> next(action)
116116
}

0 commit comments

Comments
 (0)