Skip to content

Commit aac7c11

Browse files
authored
Merge pull request #20 from patjackson52/feature/generic
clean up;
2 parents a1705d0 + 16e3a84 commit aac7c11

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.beyondeye.reduks.Action
44
import com.willowtreeapps.common.repo.ItemsHolder
55
import com.willowtreeapps.common.repo.Profile
66

7-
sealed class Actions : Action {
7+
internal sealed class Actions : Action {
88

99
class FetchingItemsStartedAction
1010
class FetchingItemsSuccessAction(val itemsHolder: ItemsHolder)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import kotlin.random.Random
99
* Reducers and functions used by reducers are in this file. Functions must be pure functions without
1010
* side effects.
1111
*/
12-
fun reducer(state: AppState, action: Any): AppState =
12+
internal fun reducer(state: AppState, action: Any): AppState =
1313
when (action) {
1414
is FetchingItemsStartedAction -> state.copy(isLoadingItems = true)
1515
is FetchingItemsSuccessAction -> {

common/src/commonMain/kotlin/com/willowtreeapps/common/middleware/NavigationMiddleware.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.beyondeye.reduks.Store
44
import com.willowtreeapps.common.Actions
55
import com.willowtreeapps.common.AppState
66

7-
class NavigationMiddleware(val navigator: Navigator) {
7+
internal class NavigationMiddleware(private val navigator: Navigator) {
88

99
fun dispatch(store: Store<AppState>, nextDispatcher: (Any) -> Any, action: Any): Any {
1010
val result = nextDispatcher(action)

common/src/commonMain/kotlin/com/willowtreeapps/common/middleware/SettingsMiddleware.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import kotlin.coroutines.CoroutineContext
1414
/**
1515
* Save and Loads user settings from local storage
1616
*/
17-
class SettingsMiddleware(private val settings: LocalStorageSettingsRepository,
17+
internal class SettingsMiddleware(private val settings: LocalStorageSettingsRepository,
1818
private val backgroundContext: CoroutineContext): CoroutineScope {
1919
override val coroutineContext: CoroutineContext
2020
get() = backgroundContext + Job()

common/src/commonMain/kotlin/com/willowtreeapps/common/middleware/ViewEffectsMiddleware.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ typealias ViewEffectsSubscriber = (ViewEffect) -> Unit
1616
*
1717
* Must be unsubscribed to avoid leaks.
1818
*/
19-
class ViewEffectsMiddleware {
19+
internal class ViewEffectsMiddleware {
2020
private val viewEffectsSubscribers = mutableSetOf<ViewEffectsSubscriber>()
2121

2222
fun subscribeToViewEffects(subscriber: ViewEffectsSubscriber) {

common/src/commonMain/kotlin/com/willowtreeapps/common/ui/PresenterFactory.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal class PresenterFactory(private val gameEngine: GameEngine, networkConte
1818
private var subscription: StoreSubscription? = null
1919

2020
private val startPresenter by lazy { StartPresenter(gameEngine.appStore, networkThunks) }
21-
private val questPresenter by lazy { QuestionPresenter(gameEngine.appStore, gameEngine.vibrateUtil, timerThunks) }
21+
private val questionPresenter by lazy { QuestionPresenter(gameEngine.appStore, gameEngine.vibrateUtil, timerThunks) }
2222
private val gameResultsPresenter by lazy { GameResultsPresenter(gameEngine.appStore) }
2323
private val settingsPresenter by lazy { SettingsPresenter(gameEngine.appStore) }
2424

@@ -34,8 +34,8 @@ internal class PresenterFactory(private val gameEngine: GameEngine, networkConte
3434
startPresenter
3535
}
3636
is QuestionView -> {
37-
questPresenter.attachView(view)
38-
questPresenter
37+
questionPresenter.attachView(view)
38+
questionPresenter
3939
}
4040
is GameResultsView -> {
4141
gameResultsPresenter.attachView(view)
@@ -56,7 +56,7 @@ internal class PresenterFactory(private val gameEngine: GameEngine, networkConte
5656
if (view is StartView)
5757
startPresenter.detachView(view)
5858
if (view is QuestionView)
59-
questPresenter.detachView(view)
59+
questionPresenter.detachView(view)
6060
if (view is GameResultsView)
6161
gameResultsPresenter.detachView(view)
6262
if (view is SettingsView)
@@ -68,14 +68,14 @@ internal class PresenterFactory(private val gameEngine: GameEngine, networkConte
6868
}
6969
}
7070

71-
private fun hasAttachedViews() = !startPresenter.isAttached() && !questPresenter.isAttached() && !gameResultsPresenter.isAttached()
71+
private fun hasAttachedViews() = !startPresenter.isAttached() && !questionPresenter.isAttached() && !gameResultsPresenter.isAttached()
7272

7373
override fun onStateChange() {
7474
if (startPresenter.isAttached()) {
7575
startPresenter.onStateChange(gameEngine.appStore.state)
7676
}
77-
if (questPresenter.isAttached()) {
78-
questPresenter.onStateChange(gameEngine.appStore.state)
77+
if (questionPresenter.isAttached()) {
78+
questionPresenter.onStateChange(gameEngine.appStore.state)
7979
}
8080
if (gameResultsPresenter.isAttached()) {
8181
gameResultsPresenter.onStateChange(gameEngine.appStore.state)

common/src/commonMain/kotlin/com/willowtreeapps/common/util/ProfileUtil.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package com.willowtreeapps.common.util
22

33
import com.willowtreeapps.common.Logger
44

5+
/**
6+
* Prints the number of milliseconds to complete given function
7+
*/
58
inline fun <T> profile(label: String, f: () -> T): T {
69
val startMs = TimeUtil.systemTimeMs()
710
val result = f()

0 commit comments

Comments
 (0)