Zhuinden/realm-monarchy

`PagedLiveResults` support (when paging lib is 1.0)

Zhuinden opened this issue ยท 16 comments

`PagedLiveResults` support (when paging lib is 1.0)

paging lib is 1.0 ๐Ÿ˜œ. also, thanks for the great work!

@lucamtudor thanks for the notice!

I've actually successfully hidden RealmResults as a positional data source, I just have to merge the other repo sample into an optional module of monarchy.

Glad to see someone's actually looking out for Monarchy, I haven't really heard anything about it from anyone since I've made it and that was apparently 5 months ago ๐Ÿ˜„

@Zhuinden I'm back in the realm game after a year of firebase projects and I was looking into new best practices & stuff like that, especially with the new arch-components being so awesome and useful. Still not sure if bleeding realm into my view/view-models is such a good idea ๐Ÿ™‚. I was hoping someone else already went through the trouble of doing all the research ๐Ÿ˜‡๐Ÿ˜‚, but I'm not that lucky :). Thoughts?

@lucamtudor Realm has an architecture components example which got squash/committed but technically I wrote it.

There are varying degrees of Realm integration, tbh, and that sample shows how to use Realm via lazy loading, while Monarchy shows how to obtain the items to memory on background thread - its true power however is unrealized until I make the commit with the paged list support.

Still, AAC is really useful because LiveData<List<T>> is a natural wrapper over the behavior of RealmResults.

I wrote something about this around a year ago: https://hackernoon.com/musing-on-architectural-components-and-realm-and-room-and-a-look-at-reactive-clean-architecture-880c8df55abf

@Zhuinden WOW
this library(wrapper) is awesome.
I'm totally gonna switch to monarchy from realm completely.
I was looking for something like that for my last project tho.
I said that in order to encourage you to keep on working on this.
btw I'm interested in using the paging library for my new project so my question is when are you going to merge the other sample u've mentioned before? :)

Great work, any plan to make this as a library?
I have been using realm for quite some times and am happy with it so no plan to use room any time soon, but I liked paging library features and especially the placeholder or continuous load mechanism. So I want to use paging and realm to gather.

When I stop being a lazy bum, I have about 4 things I should be doing! :D

But more importantly, I need to figure out how to make Jitpack's plugin publish two library modules from this repo, because Paging has to be an additional module.

According to https://github.com/afollestad/material-dialogs/blob/1726e5b088baa180b353fed9a389c6f41942239b/core/build.gradle it should work with the schema defined in jitpack/jitpack.io#203

compile 'com.afollestad.material-dialogs:core:0.8.0.0'

I'll need this as a reference for introduction of paging module.


I didn't realize people were waiting for this! I'll try to figure it out this coming week.

I already have a working sample with RealmResults being queried on a background looper thread as a positional data source, so it shouldn't be that hard to bring it over.

I really was putting it off because it's like, you try to publish to Jitpack and if you mess up the publish process it just stays there o_o but gotta do it eventually anyways, might as well figure it out on this one

In the end, it's not possible to make it a separate module because I actually couldn't even move them out of the Monarchy class. Gotta talk to a bunch of private stuff.

But good news everyone, I've added it and it should be released as 0.2.0 0.2.1

Rejoice!

52ea74b

@lucamtudor @mhdtouban @shayan3985 if I didn't mess anything up then you should be able to utilize the full power of AAC Paging on top of Realm ๐Ÿ‘

see

DataSource.Factory<Integer, RealmDog> realmDataSourceFactory = monarchy.createDataSourceFactory(realm -> realm.where(
RealmDog.class));
dataSourceFactory = realmDataSourceFactory.map(input -> Dog.create(input.getName()));
dogs = monarchy.findAllPagedWithChanges(realmDataSourceFactory,
new LivePagedListBuilder<>(dataSourceFactory, 20));

Scratch that, I'll have to release a patch. -_-

Okay, 0.2.1 should do the trick.

@Zhuinden I'll test that tomorrow and let you know how it goes.

@mhdtouban does it blend?

I didn't had chance to test it, maybe tomorrow.

I've just tested it and it's been working perfectly so far.
Good job!

You guys might want to update to 0.2.2 though because another guy found something stupid (albeit unrelated) that's been in there since December, but that's just how these things go ๐Ÿ˜„