Suppose we are getting a generic Object
from SharedPrefs
using .create()
:
return Observable.create(subscriber -> {
String json = sharedPreferences.getString(key, "");
T myClass = gson.fromJson(json, generic);
subscriber.onNext(myClass);
subscriber.onComplete();
});
and using .fromCallable()
:
return Observable.fromCallable(() -> {
String json = sharedPreferences.getString(key, "");
return gson.fromJson(json, generic);
});
Is there any Difference if we call onComplete()
immediately after first emmit from Observable.create()
and using Observable.fromCallable()
? If so, what are the pros/cons
?