Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simpler approach? #8

Closed
nightscape opened this issue Oct 21, 2016 · 1 comment
Closed

Simpler approach? #8

nightscape opened this issue Oct 21, 2016 · 1 comment

Comments

@nightscape
Copy link
Contributor

Hi @ahmedrizwan,

I'm relatively new to RxJava and also not an Android expert, so take this proposal with a grain of salt.
I have a use-case where not all items of the RecyclerView are known in advance (Bluetooth devices that are discovered dynamically).
AFAIS, this use case is not currently covered by RxRecyclerAdapter because all classes basically take a List<T> in advance and allow a certain set of operations on this list.

Now I was wondering why the classes in the library don't just accept a Observable<List<T>>. Then you wouldn't have to reimplement all those methods in RxDataSource because you could just pass an Observable which has all those operations applied already.

I've drafted a minimal working example here.
Do you see any problems with that approach?
Would this be worthy a direction to pursue in RxRecyclerAdapter, or should I rather create this as a separate project?

@ahmedrizwan
Copy link
Owner

Hi @nightscape sorry for a very late response... I have been away from android development for some time...
Regarding your approach and suggestion, I think that's a good direction to go into... Specially the part about the library accepting Observable<List<T>>... I'll definitely see if I can integrate that in the next update...
As for the dynamic part, I think you can add items dynamically by doing this :

If it's a complete new dataSet
rxDataSource.updateDataSet(dataSet).updateAdapter();

If you want to add further items to dataSet
rxDataSource.getRxAdapter().getDataSet().addAll(dataSet).updateAdapter();

Let me know if this handles your use case... :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants