-
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.
Add ViewTransform.kt + Rename TState to TView
- Loading branch information
Showing
13 changed files
with
86 additions
and
42 deletions.
There are no files selected for viewing
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
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
Empty file.
12 changes: 12 additions & 0 deletions
12
mvi/src/main/kotlin/com/adidas/mvi/transform/ViewTransform.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.transform | ||
|
||
import com.adidas.mvi.State | ||
|
||
public abstract class ViewTransform<TView, TSideEffect> : StateTransform<State<TView, TSideEffect>> { | ||
|
||
protected abstract fun mutate(currentState: TView): TView | ||
|
||
final override fun reduce(currentState: State<TView, TSideEffect>): State<TView, TSideEffect> { | ||
return currentState.copy(view = mutate(currentState.view)) | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
mvi/src/test/kotlin/com/adidas/mvi/product/FakeProductStateTransform.kt
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
mvi/src/test/kotlin/com/adidas/mvi/product/FakeProductViewTransform.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.ViewTransform | ||
|
||
class FakeProductViewTransform(private val state: State<ProductState, ProductSideEffect>) : | ||
ViewTransform<ProductState, ProductSideEffect>() { | ||
|
||
override fun mutate(currentState: ProductState): ProductState { | ||
return state.view | ||
} | ||
} |
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
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.reducer | ||
|
||
class TestSideEffect |
14 changes: 7 additions & 7 deletions
14
mvi/src/test/kotlin/com/adidas/mvi/reducer/TestTransform.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