使用RxJava在Android上協助保存和恢復對象的庫:G-Rex
一個微型庫,用于在Android上使用RxJava協助保存和恢復對象。
用法
Say we have a class called Dino
public class Dino { public String name; public int armLength; }
You can use a GRexPersister
as a stand alone helper to store a Dino.
GRexPersister persister = new GRexPersister(getContext(), "persistence", new GsonConverter()); Dino dino = new Dino("Gregory", 37); persister.put("dinoKey", dino) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<Dino>() { @Override public void onNext(Dino dino) { //Hurrah, dino was persisted! } });
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!