-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from adidas/enhancement/remove-MviState-in-fav…
…or-of-State Enhancement/remove mvi state in favor of state
- Loading branch information
Showing
26 changed files
with
101 additions
and
164 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
mvi-declarative/src/main/kotlin/com/adidas/mvi/declarative/MviState.kt
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
mvi-declarative/src/main/kotlin/com/adidas/mvi/declarative/transform/StateTransform.kt
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...clarative/src/test/kotlin/com/adidas/mvi/declarative/transform/SideEffectTransformTest.kt
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
mvi-declarative/src/test/kotlin/com/adidas/mvi/declarative/transform/StateTransformTest.kt
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...src/test/kotlin/com/adidas/mvi/declarative/transform/product/FakeProductStateTransform.kt
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
mvi-declarative/src/test/kotlin/com/adidas/mvi/declarative/transform/product/ProductState.kt
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.adidas.mvi | ||
|
||
public interface LoggableState : Loggable |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package com.adidas.mvi | ||
|
||
public interface State : Loggable | ||
import com.adidas.mvi.sideeffects.SideEffects | ||
|
||
public data class State<out TState, TSideEffect>(val view: TState, val sideEffects: SideEffects<TSideEffect>) : LoggableState |
13 changes: 7 additions & 6 deletions
13
...idas/mvi/declarative/ReducerExtensions.kt → ...m/adidas/mvi/reducer/ReducerExtensions.kt
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
8 changes: 4 additions & 4 deletions
8
mvi/src/main/kotlin/com/adidas/mvi/requirements/ReduceExtensions.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
package com.adidas.mvi.requirements | ||
|
||
import com.adidas.mvi.State | ||
import com.adidas.mvi.LoggableState | ||
|
||
public inline fun <TState : State, reified TRequiredState : TState> requireAndReduceState( | ||
public inline fun <TState : LoggableState, reified TRequiredState : TState> requireAndReduceState( | ||
state: TState, | ||
noinline reduce: (TRequiredState) -> TState | ||
): TState { | ||
return StateReduceRequirement(TRequiredState::class, reduce).reduce(state) | ||
} | ||
|
||
public inline fun <TState : State, reified TRequiredState : TState> requireState( | ||
public inline fun <TState : LoggableState, reified TRequiredState : TState> requireState( | ||
noinline reduce: (TRequiredState) -> TState | ||
): ReduceRequirement<TState> { | ||
return StateReduceRequirement(TRequiredState::class, reduce) | ||
} | ||
|
||
public infix fun <TState : State> ReduceRequirement<TState>.or(another: ReduceRequirement<TState>): ReduceRequirement<TState> { | ||
public infix fun <TState : LoggableState> ReduceRequirement<TState>.or(another: ReduceRequirement<TState>): ReduceRequirement<TState> { | ||
return DoubleReduceRequirement(this, another) | ||
} |
4 changes: 2 additions & 2 deletions
4
mvi/src/main/kotlin/com/adidas/mvi/requirements/StateReduceRequirement.kt
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
9 changes: 4 additions & 5 deletions
9
...larative/transform/SideEffectTransform.kt → ...idas/mvi/transform/SideEffectTransform.kt
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
4 changes: 2 additions & 2 deletions
4
...product/FakeProductSideEffectTransform.kt → ...product/FakeProductSideEffectTransform.kt
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
12 changes: 12 additions & 0 deletions
12
mvi/src/test/kotlin/com/adidas/mvi/product/FakeProductStateTransform.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.adidas.mvi.product | ||
|
||
import com.adidas.mvi.State | ||
import com.adidas.mvi.transform.StateTransform | ||
|
||
class FakeProductStateTransform(private val state: State<ProductState, ProductSideEffect>) : | ||
StateTransform<ProductState> { | ||
|
||
override fun reduce(currentState: ProductState): ProductState { | ||
return state.view | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ve/transform/product/ProductSideEffect.kt → ...m/adidas/mvi/product/ProductSideEffect.kt
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.adidas.mvi.product | ||
|
||
import com.adidas.mvi.LoggableState | ||
|
||
sealed class ProductState : LoggableState { | ||
object Loading : ProductState() | ||
object Loaded : ProductState() | ||
} |
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
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
4 changes: 2 additions & 2 deletions
4
mvi/src/test/kotlin/com/adidas/mvi/requirements/ReduceRequirementTests.kt
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
22 changes: 22 additions & 0 deletions
22
mvi/src/test/kotlin/com/adidas/mvi/transform/SideEffectTransformTest.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.adidas.mvi.transform | ||
|
||
import com.adidas.mvi.State | ||
import com.adidas.mvi.product.FakeProductSideEffectTransform | ||
import com.adidas.mvi.product.ProductSideEffect | ||
import com.adidas.mvi.product.ProductState | ||
import com.adidas.mvi.sideeffects.SideEffects | ||
import io.kotest.core.spec.style.ShouldSpec | ||
import io.kotest.matchers.collections.shouldContainExactly | ||
|
||
class SideEffectTransformTest : ShouldSpec({ | ||
|
||
context("SideEffectTransform") { | ||
val sideEffect = ProductSideEffect.NavigateToProductDetailsSideEffect | ||
|
||
should("use mutate() function for reducing SideEffects") { | ||
val state = State(ProductState.Loading, SideEffects<ProductSideEffect>()) | ||
FakeProductSideEffectTransform(sideEffect).reduce(state).sideEffects shouldContainExactly | ||
listOf<ProductSideEffect>(sideEffect) | ||
} | ||
} | ||
}) |
Oops, something went wrong.