-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove "Representation" from generics Signed-off-by: mramotar <[email protected]> * Remove "Representation" from generics Signed-off-by: mramotar <[email protected]> * Rename to Validator Signed-off-by: mramotar <[email protected]> * Add logo! Signed-off-by: mramotar <[email protected]> * Update README.md Signed-off-by: mramotar <[email protected]> * Format Signed-off-by: mramotar <[email protected]> * Update CI Signed-off-by: Matt <[email protected]> * Remove "Representation" from generics Signed-off-by: mramotar <[email protected]> * Remove "Representation" from generics Signed-off-by: mramotar <[email protected]> * Rename to Validator Signed-off-by: mramotar <[email protected]> * Add logo! Signed-off-by: mramotar <[email protected]> * Update README.md Signed-off-by: mramotar <[email protected]> * Format Signed-off-by: mramotar <[email protected]> * Rename generics Signed-off-by: mramotar <[email protected]> * Rename input to value Signed-off-by: mramotar <[email protected]> * Update README Signed-off-by: mramotar <[email protected]> * Update README Signed-off-by: mramotar <[email protected]> Signed-off-by: mramotar <[email protected]> Signed-off-by: Matt <[email protected]>
- Loading branch information
1 parent
855a7bb
commit ae07e06
Showing
45 changed files
with
450 additions
and
694 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
47 changes: 47 additions & 0 deletions
47
store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/Converter.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,47 @@ | ||
package org.mobilenativefoundation.store.store5 | ||
|
||
interface Converter<Network : Any, Output : Any, Local : Any> { | ||
fun fromNetworkToOutput(network: Network): Output? | ||
fun fromOutputToLocal(common: Output): Local? | ||
fun fromLocalToOutput(sourceOfTruth: Local): Output? | ||
|
||
class Builder<Network : Any, Output : Any, Local : Any> { | ||
|
||
private var fromOutputToLocal: ((value: Output) -> Local)? = null | ||
private var fromNetworkToOutput: ((value: Network) -> Output)? = null | ||
private var fromLocalToOutput: ((value: Local) -> Output)? = null | ||
|
||
fun build(): Converter<Network, Output, Local> = | ||
RealConverter(fromOutputToLocal, fromNetworkToOutput, fromLocalToOutput) | ||
|
||
fun fromOutputToLocal(converter: (value: Output) -> Local): Builder<Network, Output, Local> { | ||
fromOutputToLocal = converter | ||
return this | ||
} | ||
|
||
fun fromLocalToOutput(converter: (value: Local) -> Output): Builder<Network, Output, Local> { | ||
fromLocalToOutput = converter | ||
return this | ||
} | ||
|
||
fun fromNetworkToOutput(converter: (value: Network) -> Output): Builder<Network, Output, Local> { | ||
fromNetworkToOutput = converter | ||
return this | ||
} | ||
} | ||
} | ||
|
||
private class RealConverter<Network : Any, Output : Any, Local : Any>( | ||
private val fromOutputToLocal: ((value: Output) -> Local)?, | ||
private val fromNetworkToOutput: ((value: Network) -> Output)?, | ||
private val fromLocalToOutput: ((value: Local) -> Output)?, | ||
) : Converter<Network, Output, Local> { | ||
override fun fromNetworkToOutput(network: Network): Output? = | ||
fromNetworkToOutput?.invoke(network) | ||
|
||
override fun fromOutputToLocal(common: Output): Local? = | ||
fromOutputToLocal?.invoke(common) | ||
|
||
override fun fromLocalToOutput(sourceOfTruth: Local): Output? = | ||
fromLocalToOutput?.invoke(sourceOfTruth) | ||
} |
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
store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/FetcherResult.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: 0 additions & 22 deletions
22
store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/ItemValidator.kt
This file was deleted.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/MutableStore.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,8 +1,8 @@ | ||
package org.mobilenativefoundation.store.store5 | ||
|
||
interface MutableStore<Key : Any, CommonRepresentation : Any> : | ||
Read.StreamWithConflictResolution<Key, CommonRepresentation>, | ||
Write<Key, CommonRepresentation>, | ||
Write.Stream<Key, CommonRepresentation>, | ||
interface MutableStore<Key : Any, Output : Any> : | ||
Read.StreamWithConflictResolution<Key, Output>, | ||
Write<Key, Output>, | ||
Write.Stream<Key, Output>, | ||
Clear.Key<Key>, | ||
Clear |
4 changes: 2 additions & 2 deletions
4
store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/OnFetcherCompletion.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,6 +1,6 @@ | ||
package org.mobilenativefoundation.store.store5 | ||
|
||
data class OnFetcherCompletion<NetworkRepresentation : Any>( | ||
val onSuccess: (FetcherResult.Data<NetworkRepresentation>) -> Unit, | ||
data class OnFetcherCompletion<Network : Any>( | ||
val onSuccess: (FetcherResult.Data<Network>) -> Unit, | ||
val onFailure: (FetcherResult.Error) -> Unit | ||
) |
2 changes: 1 addition & 1 deletion
2
store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/OnUpdaterCompletion.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,6 +1,6 @@ | ||
package org.mobilenativefoundation.store.store5 | ||
|
||
data class OnUpdaterCompletion<NetworkWriteResponse : Any>( | ||
data class OnUpdaterCompletion<Response : Any>( | ||
val onSuccess: (UpdaterResult.Success) -> Unit, | ||
val onFailure: (UpdaterResult.Error) -> Unit | ||
) |
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
Oops, something went wrong.