Skip to content
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

[Feature Request] Please add better documentation #277

Open
itsandreramon opened this issue Jun 7, 2021 · 1 comment
Open

[Feature Request] Please add better documentation #277

itsandreramon opened this issue Jun 7, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@itsandreramon
Copy link

itsandreramon commented Jun 7, 2021

Please provide a better documentation on how to use it with different use cases. For instance reading all items or reading a single item using Store. While I know how to setup this up, best practices are not clear from the current readme.

Also, the example omits precious type information and locally used datasource to be able to use method references like shown here:

StoreBuilder
    .from(
        fetcher = Fetcher.of { api.fetchSubreddit(it, "10").data.children.map(::toPosts) },
        sourceOfTruth = SourceOfTruth.of(
            reader = db.postDao()::loadPosts,
            writer = db.postDao()::insertPosts,
            delete = db.postDao()::clearFeed,
            deleteAll = db.postDao()::clearAllFeeds
        )
    ).build()

Maybe consider adding a sample?

Also, how to handle Nullability inside the fetcher? What if my API does return null? The Store only accepts Any as output or is this something that is handled internally and then it just returns the onError response?

@itsandreramon itsandreramon added the enhancement New feature or request label Jun 7, 2021
@digitalbuddha
Copy link
Contributor

digitalbuddha commented Jun 7, 2021

https://github.com/dropbox/Store/tree/main/app should have a sample or two but is primed for a refactor. Let me think about some improvements.

As for nullability inside a fetcher you have two options: if null is a valid value I would recommend transforming/wrap it (null object pattern). If null is an unexpected value I'd recommend throwing an exception instead. I'm afk today but will link the past issues/discussions about null handling.

Hope that helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants