While I think I've got a handle on the basics of how to use RxJava, I'm having trouble using the Observer pattern.
Basically, what I want to do is have a static List
of objects that I can monitor, and use additions to the list to submit this data to a webservice.
My approach so far has to just been create a static List<Object>
and a static Observable<Object>
. This observable is created by just doing a
observable = Observable.from(listOfObjects);
Then, I have my upload logic inside of a .subscribe()
call. This would work if I had the List
all set up ahead of time, but I want to populate it here and there at runtime. This will still work if I call .subscribe()
again, but it feels like I am doing something wrong by doing that. I thought I could get the existing subscription to just act on any new items emitted from the observable, but nothing seems to be happening when I add to the list.
Any insight on a better/correct approach is appreciated.