-
Notifications
You must be signed in to change notification settings - Fork 215
Yigit/move fetcher factories to fetcher #168
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
Changes from 5 commits
2abe777
3345836
b51e2b0
d7b0970
9a56e8e
e1bce0b
f3b6fc4
220f771
7a2ad14
a79f652
de9a916
408b22f
705e9c1
248ccc0
b3d7c9a
510214d
989cbf4
fdb26ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,9 +56,9 @@ Let's start by looking at what a fully configured Store looks like. We will then | |
| ```kotlin | ||
| StoreBuilder | ||
| .from( | ||
| fetcher = nonFlowValueFetcher { api.fetchSubreddit(it, "10").data.children.map(::toPosts) }, | ||
| fetcher = Fetcher.from { api.fetchSubreddit(it, "10").data.children.map(::toPosts) }, | ||
| sourceOfTruth = SourceOfTrue.from( | ||
| reader = db.postDao()::loadPosts, | ||
| flowReader = db.postDao()::loadPosts, | ||
|
||
| writer = db.postDao()::insertPosts, | ||
| delete = db.postDao()::clearFeed, | ||
| deleteAll = db.postDao()::clearAllFeeds | ||
|
|
@@ -81,7 +81,7 @@ You create a Store using a builder. The only requirement is to include a `Fetche | |
|
|
||
| ```kotlin | ||
| val store = StoreBuilder | ||
| .from(valueFetcher { articleId -> api.getArticle(articleId) }) // api returns Flow<Article> | ||
| .from(Fetcher.fromFlow { articleId -> api.getArticle(articleId) }) // api returns Flow<Article> | ||
| .build() | ||
| ``` | ||
|
|
||
|
|
@@ -186,9 +186,9 @@ allows you to create offline first applications that can be used without an acti | |
| ```kotlin | ||
| StoreBuilder | ||
| .from( | ||
| fetcher = nonFlowValueFetcher { api.fetchSubreddit(it, "10").data.children.map(::toPosts) }, | ||
| fetcher = Fetcher.from { api.fetchSubreddit(it, "10").data.children.map(::toPosts) }, | ||
| sourceOfTruth = SourceOfTrue.from( | ||
| reader = db.postDao()::loadPosts, | ||
| flowReader = db.postDao()::loadPosts, | ||
| writer = db.postDao()::insertPosts, | ||
| delete = db.postDao()::clearFeed, | ||
| deleteAll = db.postDao()::clearAllFeeds | ||
|
|
@@ -215,9 +215,9 @@ You can configure in-memory cache with the `MemoryPolicy`: | |
| ```kotlin | ||
| StoreBuilder | ||
| .from( | ||
| fetcher = nonFlowValueFetcher { api.fetchSubreddit(it, "10").data.children.map(::toPosts) }, | ||
| fetcher = Fetcher.from { api.fetchSubreddit(it, "10").data.children.map(::toPosts) }, | ||
| sourceOfTruth = SourceOfTrue.from( | ||
| reader = db.postDao()::loadPosts, | ||
| flowReader = db.postDao()::loadPosts, | ||
| writer = db.postDao()::insertPosts, | ||
| delete = db.postDao()::clearFeed, | ||
| deleteAll = db.postDao()::clearAllFeeds | ||
|
|
@@ -244,8 +244,9 @@ You can delete a specific entry by key from a store, or clear all entries in a s | |
|
|
||
| ```kotlin | ||
| val store = StoreBuilder | ||
| .from(nonFlowValueFetcher { api.fetchData(key) }) | ||
| .build() | ||
| .from(Fetcher.from { key: String -> | ||
| api.fetchData(key) | ||
| }).build() | ||
| ``` | ||
|
|
||
| The following will clear the entry associated with the key from the in-memory cache: | ||
|
|
@@ -267,9 +268,9 @@ When store has a sourceOfTruth, you'll need to provide the `delete` and `deleteA | |
| ```kotlin | ||
| StoreBuilder | ||
| .from( | ||
| fetcher = nonFlowValueFetcher { api.fetchData(key) }, | ||
| fetcher = Fetcher.from { api.fetchData(key) }, | ||
| sourceOfTruth = SourceOfTrue.from( | ||
| reader = dao::loadData, | ||
| flowReader = dao::loadData, | ||
| writer = dao::writeData, | ||
| delete = dao::clearDataByKey, | ||
| deleteAll = dao::clearAllData | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.