README updated to reflect changes from rx2 (#243)
This commit is contained in:
parent
bf79676dad
commit
325ce19abf
1 changed files with 5 additions and 5 deletions
10
README.md
10
README.md
|
@ -41,7 +41,7 @@ And now for the details:
|
|||
|
||||
### Creating a Store
|
||||
|
||||
You create a Store using a builder. The only requirement is to include a `.Fetcher<ReturnType,KeyType>` that returns an Observable<ReturnType> and has a single method `fetch(key)`
|
||||
You create a Store using a builder. The only requirement is to include a `.Fetcher<ReturnType,KeyType>` that returns an Single<ReturnType> and has a single method `fetch(key)`
|
||||
|
||||
|
||||
``` java
|
||||
|
@ -68,7 +68,7 @@ When using a Barcode as your key, you can use a StoreBuilder convenience method
|
|||
### Public Interface - Get, Fetch, Stream, GetRefreshing
|
||||
|
||||
```java
|
||||
Observable<Article> article = store.get(barCode);
|
||||
Single<Article> article = store.get(barCode);
|
||||
```
|
||||
|
||||
The first time you subscribe to `store.get(barCode)`, the response will be stored in an in-memory cache. All subsequent calls to `store.get(barCode)` with the same Key will retrieve the cached version of the data, minimizing unnecessary data calls. This prevents your app from fetching fresh data over the network (or from another external data source) in situations when doing so would unnecessarily waste bandwidth and battery. A great use case is any time your views are recreated after a rotation, they will be able to request the cached data from your Store. Having this data available can help you avoid the need to retain this in the view layer.
|
||||
|
@ -178,7 +178,7 @@ Store<Article,Integer> store = StoreBuilder.<Integer, BufferedSource, Article>pa
|
|||
.fetcher(articleId -> api.getArticles())
|
||||
.persister(new Persister<BufferedSource>() {
|
||||
@Override
|
||||
public Observable<BufferedSource> read(Integer key) {
|
||||
public Maybe<BufferedSource> read(Integer key) {
|
||||
if (dataIsCached) {
|
||||
return Observable.fromCallable(() -> userImplementedCache.get(key));
|
||||
} else {
|
||||
|
@ -187,9 +187,9 @@ Store<Article,Integer> store = StoreBuilder.<Integer, BufferedSource, Article>pa
|
|||
}
|
||||
|
||||
@Override
|
||||
public Observable<Boolean> write(BarCode barCode, BufferedSource source) {
|
||||
public Single<Boolean> write(BarCode barCode, BufferedSource source) {
|
||||
userImplementedCache.save(key, source);
|
||||
return Observable.just(true);
|
||||
return Single.just(true);
|
||||
}
|
||||
})
|
||||
.parser(GsonParserFactory.createSourceParser(gson, Article.class))
|
||||
|
|
Loading…
Reference in a new issue