Skip to content

[WIP] split read and write SOT types #560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 5, 2023
Merged

[WIP] split read and write SOT types #560

merged 7 commits into from
Jul 5, 2023

Conversation

digitalbuddha
Copy link
Contributor

Need to fix some of the newer tests and document. Fixes #559 #558

@digitalbuddha digitalbuddha changed the title WIP split read and write SOT types [WIP] split read and write SOT types Jun 13, 2023
Copy link
Collaborator

@matt-ramotar matt-ramotar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. I wonder if we should separate the converter for Store and MutableStore usage. I think when we support #554 users would otherwise find fromOutputToLocal confusing. The failing test is with generics in rx2

Comment on lines +13 to +14
fun fromNetworkToLocal(network: Network): Local
fun fromOutputToLocal(output: Output): Local
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is OutputToLocal is only used with MutableStore. Should this interface be separated?

@@ -55,7 +56,16 @@ internal class FetcherController<Key : Any, Network : Any, Output : Any, Local :
*/
private val sourceOfTruth: SourceOfTruthWithBarrier<Key, Network, Output, Local>?,

private val converter: Converter<Network, Output, Local>? = null
private val converter: Converter<Network, Local, Output> = object : Converter<Network, Local, Output> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining why it is safe to use this object as the converter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to a bit of tangling between store and mutable store. In store, there is no concept of local, the network type is always the same as what is going into the source of truth. This default parameter keeps us from having to pass in that dummy everywhere. The second function fromOutputToLocal will never be called, I'll throw an exception from there.

private val memoryCache: Cache<Key, Output>? = null,
private val converter: Converter<Network, Local, Output> = object :
Converter<Network, Local, Output> {
override fun fromOutputToLocal(output: Output): Local =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fromOutputToLocal method is only invoked internally right? Should the error message convey it's not an issue with their usage?

@digitalbuddha
Copy link
Contributor Author

@matt-ramotar UpdaterTests was failing for me locally, I don't think it was rx related

digitalbuddha and others added 2 commits June 21, 2023 14:43
Signed-off-by: Matt Ramotar <mramotar@dropbox.com>
@notion-workspace
Copy link

Merge

@digitalbuddha digitalbuddha merged commit 2499d6e into main Jul 5, 2023
itsandreramon pushed a commit to itsandreramon/Store that referenced this pull request Feb 26, 2025
* split read and write SOT types

* all but 2 tests passing

* remove extranous parameterized type on simple store factory

* pr review

* pr review

* Passing except for UpdaterTests (MobileNativeFoundation#565)

Signed-off-by: Matt Ramotar <mramotar@dropbox.com>

* mark mutablestore experimental

---------

Signed-off-by: Matt Ramotar <mramotar@dropbox.com>
Co-authored-by: Matt Ramotar <mramotar@dropbox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BUG] Fix breaking changes with source of truth
2 participants