Rxについて多くの文献を読んでいますが、一方ではすべてが明確ですが、他方では何も明らかではありません。私はこのライブラリを使ってサーバーからデータを簡単にフィルタリングして保存しようとしていますが、期待どおりに動作していません。私は、単純なチャンネルリスト管理を実装する必要があります。RxAndroid。単純なキャッシングとデータのフィルタリング
1. Cache on disk and in memory
2. When user requested - return filtered channels
3. All Subscribers that was attached to this Observable must be notified if filtered cahnnels list was changed (call onNext() for all Subscribers)
私は次のように書いた:
ArrayList<Channel> channels = null;
ArrayList<Channel> filteredChannels = null;
Observable<ArrayList<Channel>> filteredObservable = Observable.create()
// here I need to check if cache is valid, if no - download from server
// then filter channels and return filteredChannels in onNext call
// all subscribers that called subscribe before and not called unsubscribe must be notified if filteredChannels changed
// how to implement this?
.subscribeOn(Schedulers.io());
public void setFilter(Filter filter) {
// update filteredChannels with the new filter and notify all Subscribers (call onNext()). How to implement this?
}
public Observable<ArrayList<Channel>> getFilteredChannels() {
return filteredObservable;
}
私が正しく受信パターンの論理を理解したりしないでください?前もって感謝します。