vicpinm / Kotlin-Realm-Extensions

Kotlin extensions to simplify Realm API.
Apache License 2.0
535 stars 53 forks source link

RealmConfiguration update #13

Closed magillus closed 7 years ago

magillus commented 7 years ago

I think right now the extensions are limited to single RealmConfiguration (default).

Maybe we can introduce a extension method that would wrap into additional configurations, like: User("testuser").realm(realmConfig).save() or User("testuser").save(realmConfig)

Or even remember configuration per Module/RealmObject or set it via initialization.

magillus commented 7 years ago

I will dig into co-routines, maybe there is some hope for this. I will keep this ticket posted

magillus commented 7 years ago

I come up with this solution, still not final and not working fully (saveAll from Array/Collection): https://github.com/magillus/Kotlin-Realm-Extensions/pull/1/files However it does some job done, I will try to update it for full support.

vicpinm commented 7 years ago

Hi @magillus, additional configurations is something I had in mind but it wasn't one of my priorities. I think you have done a great job, and I'll be pleased to merge your commit into master when you have finished. I will look into your changes deeper this week and keep this issue opened to track your request.

Thank you very much.

magillus commented 7 years ago

Cool, thanks! I will try to wrap this PR up and add more comments where needed in upcoming week.

magillus commented 7 years ago

The PR need to wait to removing the RxJava1/2 from dependencies, got some errors on that front. I did some updates and latest master merge, and I plan to add Unit test (if time permits next week)

magillus commented 7 years ago

Also not sure about TestRealmConfigurationFactory etc. got errors on it with my PR, when I get a chance I will try to read code for it to understand.

JimClermonts commented 7 years ago

We need this enhancement as well. Is this coming any time soon?

vicpinm commented 7 years ago

Hi  @JimClermonts, I don't know if @magillus have plans to send me a PR. If not, I can do it in the next week. I will wait for a few days and if I dont have any update, I will try to make time to do it.

JimClermonts commented 7 years ago

@vicpinm keep me updated. Maybe we can also do it. We love this extension.

magillus commented 7 years ago

I am so sorry for delay, I was away on vacation. I try to update the PR: https://github.com/magillus/Kotlin-Realm-Extensions/pull/1/files based on latest, (edit: asap)

vicpinm commented 7 years ago

Version 1.2.0-beta1 is now available with configurations per model. All models will have the default configuration, but you can specify other configurations with:

     RealmConfigStore.init(modelClass, modelConfig)
     RealmConfigStore.init(modelClass2, modelConfig2)

Version 1.2.0 is in beta but I think that it will be soon uploaded as stable.

Thanks to @magillus for his PR.