Skip to content

Instantly share code, notes, and snippets.

@patrykpoborca
Last active August 29, 2015 14:27
Show Gist options
  • Save patrykpoborca/1e47a5363bc4e0aabe06 to your computer and use it in GitHub Desktop.
Save patrykpoborca/1e47a5363bc4e0aabe06 to your computer and use it in GitHub Desktop.
public class LocalDataCache {
//pretend this is some read/write to disk :)
protected static ArrayList<String> sPastTweets;
private Context context;
public LocalDataCache(Context context) {
this.context = context;
sPastTweets = new ArrayList<>();
}
public void saveTweet(String tweet) {
sPastTweets.add(tweet);
}
public Observable<List<String>> fetchRecentTweets() {
return Observable.just(sPastTweets)
.map(arrayList -> {
List<String> list = arrayList;
return list;
})
.delay(2, TimeUnit.SECONDS);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment